QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#135614#5119. Perfect WordThunder_SWA 3ms7176kbC++14802b2023-08-05 19:39:042023-08-05 19:39:07

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:39:07]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:7176kb
  • [2023-08-05 19:39:04]
  • 提交

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'