40pts求条
查看原帖
40pts求条
1696493
Oberon_owl楼主2025/8/29 07:46

【题目传送门】

#5~10 WA;如回必关


code:code:

#include<bits/stdc++.h>
using namespace std;
string xx[1005];
int main(void){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,q;
    cin>>n>>q;
    for(int i=0;i<n;i++)cin>>xx[i];
    sort(xx,xx+n);
    for(int i=0;i<q;i++){
        int y;
        string z;
        cin>>y>>z;
        bool f=false;
        for(int j=0;j<n;j++){
            string x=xx[j];
            if(x.length()<y)continue;
            string e=x.substr(x.length()-y);
            if(e==z){
                cout<<x<<endl;
                f=true;
                break;
            }
        }
        if(!f)cout<<-1<<endl;
    }
    return 0;
}

2025/8/29 07:46
加载中...