ZY_2007 @ 2019-11-13 19:23:28
不知道为什么这个居然编译不了
//
// main.cpp
// 2
//
// Created by Shellpicker on 2019/11/12.
// Copyright © 2019 XZY. All rights reserved.
//
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
const int sim=1000;
const int lim=2000;
int n,q;
int len[sim+1];
string book[lim+1],code[sim+1];
bool cmp(int i,int j);
int main(int argc, const char * argv[]) {
// insert code here...
cin>>n>>q;
for(int i=1;i<=n;i++)
cin>>book[i];
sort(book+1,book+n+1,cmp);
for(int i=1;i<=q;i++){
cin>>len[i];
cin>>code[i];
}
for(int i=1;i<=q;i++){
bool f=false;
for(int j=1;j<=n;j++){
bool sec=true;
int l=len[i];
for(int k=1;k<=l;k++)
if(book[i][book[i].length()-l+k]!=code[i][k]){
sec=false;
break;
}
if(sec==true){
f=true;
cout<<i<<endl;
break;
}
}
if(f==false)
cout<<"-1"<<endl;
}
//std::cout << "Hello, World!\n";
return 0;
}
bool cmp(int i,int j){
return i>j;
}
by Stephen_Curry @ 2019-11-13 19:29:07
@颜正元 你的排序函数的变量类型和cmp变量类型不统一啊
by ZY_2007 @ 2019-11-13 19:30:19
@Stephen_Curry 嗯,懂了
by Clark233 @ 2019-12-15 17:14:25
啊,Xcode