QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#638550 | #5119. Perfect Word | wzxtsl# | WA | 6ms | 4924kb | C++23 | 1.1kb | 2024-10-13 16:12:55 | 2024-10-13 16:13:00 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define For(i,aa,a) for(int i=aa;i<=a;i++)
int n,m;
void solve(){
int maxx=0;
map<string,int>mp;
int n;cin>>n;
string ms[n+1];
for(int i=1;i<=n;i++){
string s;
cin>>s;
mp[s]=1;
ms[i]=s;
}
for(int j=1;j<=n;j++){
int fl=0;
string s=ms[j];
for(int i=1;i<s.length();i++){
string ss=s.substr(i,s.length()-i);
// cout<<ss<<endl;
if(!mp[ss]){
fl=1;
break;
}
}
//reverse(s.begin(),s.end());//cout<<s<<endl;
for(int i=0;i<s.length()-1;i++){
string ss=s.substr(0,i+1);
// cout<<ss<<endl;
if(!mp[ss]){
fl=1;
break;
}
}
int len=s.length();
if(!fl)maxx=max(len,maxx);
}
cout<<maxx<<endl;
}
signed main(){
fast;
int t=1;
// cin>>t;
while(t--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3820kb
input:
4 a t b ab
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 6ms
memory: 3700kb
input:
310 a aa aaa aaaa aaaaa aaaaaa aaaaaaa aaaaaaaa aaaaaaaaa aaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaa...
output:
300
result:
ok 1 number(s): "300"
Test #3:
score: 0
Accepted
time: 6ms
memory: 4540kb
input:
4347 bbaaaab aabab bbaaaaababaaaba aababaaaabbbabababaaaba ababbabbbbbabbbabbab bbbbbbb bbbabbbabbabaab aabbbbabbbbaa aabaaabbbbbabaaababaa aaabababba aaababbaabab abbababbabbab bababaabbbbaaa aaaaaabaaaababaa ababaababba babaababbbababaaab bb abbbaaaababa b ab aaabbbbb abaabaaaaababbbab bbaaabaab b...
output:
10
result:
ok 1 number(s): "10"
Test #4:
score: 0
Accepted
time: 3ms
memory: 4924kb
input:
5555 fdaaefdad eacaeb eeab decaaddfdfffeb ebcdeeceabfcded aeeabcefdfdcb abfdeeaac daddadacebffcccb abacccea bcbec ababfdaa b fbcccdbcdceafdefa bdcd a ceaabbbae e eebeddcedecacafdc ccdaebfd ceeefb baafbad fadcaefbae aad a dcdddedbdcdeabd f fdbccede ebfb efadfddddfed fafefdfbdec bcacbbafaaeddec aebfec...
output:
5
result:
ok 1 number(s): "5"
Test #5:
score: -100
Wrong Answer
time: 6ms
memory: 4680kb
input:
6249 a a aedbcbebea bcebbaabeed ebacbdbbaccdbbe cceccaacb ededaa acdabaebaedab bacdadacbec ebbeaebabcebdd bcec adc eeaaadba eedabbaea aadaadaecdcd cdbdbddbababb ea ecccbebceddbae ebaecdaebadad ddccd ebcebdcaecae bccebebdcccbdbca bccc ebccdeeedbeea aaedaeeaadbbbac bbcee caeccdbcbee acbaabecccca ea cd...
output:
6
result:
wrong answer 1st numbers differ - expected: '5', found: '6'