QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#418810 | #5119. Perfect Word | imxx | WA | 3ms | 6964kb | C++14 | 742b | 2024-05-23 15:53:34 | 2024-05-23 15:53:34 |
Judging History
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'