QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#458765 | #8829. Aibohphobia | ucup-team3474# | TL | 0ms | 3876kb | C++23 | 1.2kb | 2024-06-29 19:10:17 | 2024-06-29 19:10:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std ;
void solve()
{
string s ;
cin >> s ;
if(s.size() == 1)
{
cout << "YES\n" ;
cout << s << '\n' ;
return ;
}
map<char , int> mp ;
for(auto u : s) mp[u] += 1 ;
if(mp.size() == 1)
{
cout << "NO\n" ;
return ;
}
int flag = 0 ;
char c = 'a' ;
for(auto [d , cnt] : mp)
if(cnt == 1)
{
flag = 1 ;
c = d ;
break ;
}
if(flag == 1)
{
cout << "YES\n" ;
cout << c ;
for(auto u : s)
if(u != c)
cout << u ;
cout << '\n' ;
return ;
}
if(mp.size() == 2)
{
cout << "NO\n" ;
return ;
}
int n = s.size() ;
cout << "YES\n" ;
while(true)
{
int z = 0 ;
for(int i = 0 ; i < 26 ; i ++)
{
if(mp['a' + i] == 0) continue ;
z = 1 ;
cout << (char)('a' + i) ;
}
if(z == 0) break ;
}
}
int main()
{
std::ios::sync_with_stdio(false) , cin.tie(0) ;
int T ;
cin >> T ;
while (T --) solve() ;
return 0 ;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3840kb
input:
5 a sos abba icpc tenet
output:
YES a YES oss NO YES icpc YES nteet
result:
ok Correct (5 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3876kb
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 epvln YES jiit NO YES loo NO YES qu YES mgvgv NO NO YES ykkk YES o YES ummmm YES aetvv YES lxnt
result:
ok Correct (18 test cases)
Test #3:
score: -100
Time Limit Exceeded
input:
138 gcseqpht brrrzsrerr ree lgryyyh wbxkwwwwx hsihaga kvvslzgv dssd qhrqqqrqyh dfffffsfgf ssuzuuzzs rrwnyrcdnb ealelecu ccfwwwccwc emeieme xeexeswes ymkkkkpkk eimderoz lflllh lluylcll rquqrqu mllmllll cscscc ssssssssss cn llljlzlzj h kbbxahczit yxrrrrxlkr uikiakika tntnnqntw sjhxyfsy fcyyyf dbvbvdbw...
output:
YES cgseqpht YES brrrzsrerr YES ree YES glryyyh YES bwxkwwwwx YES ghsihaa YES gkvvslzv NO YES yqhrqqqrqh YES dfffffsfgf YES suzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsuzsu...