RT,我用的不是字典树,但不知道为啥WA了。
#include <bits/stdc++.h>
using namespace std;
string a[10005];
inline bool check(string a,string b){
for (register int i=0;i<a.size();i++){
if (a[i]!=b[i]) return 0;
}
return 1;
}
int main(){
std::ios::sync_with_stdio(0);
int t,es=0;
int n=0;
while(cin >> a[++n]){
if (a[n][0]=='9'){
n--;
sort(a+1,a+1+n);
bool ok=0;
for (register int i=1;i<=n;i++){
if (check(a[i],a[i+1])){
ok=1;
break;
}
cout << a[i] << endl;
}
if (ok) printf("Set %d is not immediately decodable\n",++es);
else printf("Set %d is immediately decodable\n",++es);
n=0;
}
}
}