题目链接:Bazinga
题目大意:给你一些字符串,问你从上到下最大的条件字符串,这个字符串需要满足在它上面的字符串不能全部都是它的子串,问最大的标记是多少
题目思路:我们可以考虑这样一个问题,如果前面的字符串全部都是这个这个字符串的子串的话,那么我们是不是只考虑这样一个字符串而不需要考虑前面的字符串,如果不是的话我们就可以标记一下记录最大值,然后这样用vector扫一下,剪下枝,扫下去就好了,时间卡的不紧,所以可以过
#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <queue>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 2e3+10;
int T,n;
string str;
int main(){
ios::sync_with_stdio(false);
cin>>T;
for(int Case = 1;Case <= T;Case++){
int maxxid=-1;
vector<string>V;
cin>>n;
cin>>str;
V.push_back(str);
for(int i=1; i<n; i++){
cin>>str;
bool flag=true;
for(int j=0; j<V.size(); j++){
if(str.find(V[j])==str.npos){
flag=false;
break;
}
}
if(flag==true)
V.clear();
else maxxid=i+1;
V.push_back(str);
}
cout<<"Case #"<<Case<<": "<<maxxid<<endl;
}
return 0;
}