QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#135607 | #5119. Perfect Word | Thunder_S | WA | 4ms | 6696kb | C++14 | 742b | 2023-08-05 19:35:00 | 2023-08-05 19:35:01 |
Judging History
answer
#include<map>
#include<cstdio>
#include<string>
#include<algorithm>
#define N 100005
using namespace std;
int n,ans;
string s[N];
map<string,bool> mp;
bool cmp(string x,string y) {return x.length()>y.length();}
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();
mp[s[i]]=true;
}
sort(s+1,s+n+1,cmp);
for (int i=1;i<=n;++i)
{
int len=s[i].length();
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: 2ms
memory: 6516kb
input:
4 a t b ab
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 2ms
memory: 6476kb
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: 4ms
memory: 6696kb
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'