QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#458777 | #8829. Aibohphobia | ucup-team3474# | WA | 1ms | 3708kb | C++23 | 1.4kb | 2024-06-29 19:15:20 | 2024-06-29 19:15:20 |
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 ;
}
vector<int> mp(26 , 0) ;
for(auto u : s) mp[u - 'a'] += 1 ;
int cc = 0 ;
for(int i = 0 ; i < 26 ; i ++)
if(mp[i] > 0)
cc += 1 ;
if(cc == 1)
{
cout << "NO\n" ;
return ;
}
int flag = 0 ;
char c = 'a' ;
for(int i = 0 ; i < 26 ; i ++)
if(mp[i] == 1)
{
flag = 1 ;
c = 'a' + i ;
break ;
}
if(flag == 1)
{
cout << "YES\n" ;
cout << c ;
for(auto u : s)
if(u != c)
cout << u ;
cout << '\n' ;
return ;
}
if(cc == 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[i] == 0) continue ;
z = 1 ;
mp[i] -= 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: 1ms
memory: 3708kb
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: 1ms
memory: 3616kb
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
Wrong Answer
time: 0ms
memory: 3544kb
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 suzsuzsuzYES brrwnyrcdn YES aelelecu YES fccwwwccwc YES iemeeme YES wxeexeses YES mykkkkpkk YES deimeroz YES fllllh YES clluylll YES qruqruqNO NO NO YES cn YES jlzjlzlllYES h Y...
result:
wrong answer Not a permutation (test case 11)