QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#418810#5119. Perfect WordimxxWA 3ms6964kbC++14742b2024-05-23 15:53:342024-05-23 15:53:34

Judging History

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

  • [2024-05-23 15:53:34]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:6964kb
  • [2024-05-23 15:53:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n;
const int maxn=1e5+10;
map<string,bool>m;
string s[maxn];
inline bool cmp(string &a,string &b){
	return a.size()<b.size();
}
inline string pr(string &t){
	string tmp="";
	for(int i=1;i<t.size();i++)tmp.push_back(t[i]);
	return tmp; 
}
inline string ed(string &t){
	string tmp="";
	for(int i=0;i<t.size()-1;i++)tmp.push_back(t[i]);
	return tmp;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>s[i];
	sort(s+1,s+n+1,cmp);
	m[""]=1;
	int ans=1;
	for(int i=1;i<=n;i++){
		if(m.find(pr(s[i]))!=m.end()||m.find(ed(s[i]))!=m.end()){
			m[s[i]]=1;
			if(s[i].size()>ans)ans=s[i].size();
		}
	}
	cout<<ans;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 6964kb

input:

4
a
t
b
ab

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 2ms
memory: 6828kb

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: 3ms
memory: 6820kb

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:

12

result:

wrong answer 1st numbers differ - expected: '10', found: '12'