QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#135606#5119. Perfect WordThunder_SWA 5ms6680kbC++14743b2023-08-05 19:34:072023-08-05 19:34:09

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-05 19:34:09]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:6680kb
  • [2023-08-05 19:34:07]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 6408kb

input:

4
a
t
b
ab

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 3ms
memory: 6596kb

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: 5ms
memory: 6680kb

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'