QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#135614 | #5119. Perfect Word | Thunder_S | WA | 3ms | 7176kb | C++14 | 802b | 2023-08-05 19:39:04 | 2023-08-05 19:39:07 |
Judging History
answer
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#define N 100005
using namespace std;
int n,ans;
string s[N];
unordered_map<string,bool> mp;
bool cmp(string &x,string &y) {return x.size()>y.size();}
int main()
{
scanf("%d",&n);
for (int i=1;i<=n;++i)
{
// char ch=getchar();
// while (ch<'a'||ch>'z') ch=getchar();
// while (ch>='a'&&ch<='z') s[i]+=ch,ch=getchar();
cin>>s[i];
mp[s[i]]=true;
}
sort(s+1,s+n+1,cmp);
for (int i=1;i<=n;++i)
{
int len=s[i].size();
bool flag=true;
for (int j=0;flag&&j<len;++j)
for (int k=1;k+j<=len;++j)
{
if (mp.find(s[i].substr(j,k))==mp.end()) {flag=false;break;}
}
if (flag)
{
printf("%d\n",s[i].size());
return 0;
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 6888kb
input:
4 a t b ab
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 3ms
memory: 6976kb
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: -100
Wrong Answer
time: 0ms
memory: 7176kb
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:
23
result:
wrong answer 1st numbers differ - expected: '10', found: '23'