u55545554 @ 2018-08-21 10:21:45
#include<iostream>
#include<cstring>
using namespace std;
struct bookes{
string book;
}books[1001];
struct needes{
string need;
}needs[1001];
struct shuchues{
string shuchu;
}shuchus[1001];
int main(){
int n,q;cin>>n>>q;
string son_string;
for(int i=1;i<=n;i++)shuchus[i].shuchu="-1";
for(int i=1;i<=n;i++)cin>>books[i].book;
for(int i=1;i<=q;i++){
cin>>needs[i].need;
for(int j=1;j<=n;j++){
son_string=books[j].book.substr(books[j].book.length()-needs[i].need.length(),needs[i].need.length());
if(son_string==needs[i].need&&son_string>shuchus[i].shuchu)shuchus[i].shuchu=son_string;
}
}
for(int i=1;i<=n;i++)cout<<shuchus[i].shuchu<<endl;
}
by u55545554 @ 2018-08-21 11:23:58
@星烁晶熠辉 谢dalao!
by 饕餮吃题目 @ 2018-09-18 21:17:09
@星烁晶熠辉 对新人要友好啊。