QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#558779 | #8829. Aibohphobia | knightofshadow# | WA | 0ms | 3532kb | C++14 | 1.1kb | 2024-09-11 18:30:35 | 2024-09-11 18:30:35 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n;
cin>>n;
string s;
while(n--){
map<ll,ll>a;
cin>>s;
ll cnt=0;
s='-'+s;
for(int i=1;i<=s.size()-1;i++){
a[s[i]-'a']++;
if(a[s[i]-'a']==1) cnt++;
}
if(cnt==1){
if(s.size()==2) {
cout<<"Yes\n";
for(auto it:a)cout<<static_cast<char>(it.first+'a')<<'\n';
}
else{
cout<<"No\n";
}
}
else if(cnt==2){
if(s.size()<=4){
cout<<"Yes\n";
char b,c;
ll f=0,cc;
for(auto it:a){
if(f==0&&it.second==1){
f=1;
b=static_cast<char>(it.first+'a');
}
else {
c=static_cast<char>(it.first+'a');
cc=it.second;
}
}
cout<<b;
for(int i=1;i<=cc;i++) cout<<c;
cout<<'\n';
}
else cout<<"No\n";
}
else{
cout<<"Yes\n";
for(auto it:a){
cout<<static_cast<char>(it.first+'a');
}
for(auto it:a){
for(int i=2;i<=it.second;i++) cout<<static_cast<char>(it.first+'a');
}
cout<<'\n';
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3456kb
input:
5 a sos abba icpc tenet
output:
Yes a Yes oss No Yes cipc Yes entet
result:
ok Correct (5 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3532kb
input:
18 qnx oooo tvttj zzzzz pvlne iijt hjhjj loo hh uq mgvgv ewwe iii kykk o mmumm aetvv xntl
output:
Yes nqx No Yes jtvtt No Yes elnpv Yes ijti No Yes loo No Yes qu Yes gmvgv No No No Yes o No Yes aetvv Yes lntx
result:
wrong answer Jury found the answer but participant didn't (test case 14)