QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#465072 | #8829. Aibohphobia | ucup-team3548# | WA | 0ms | 3588kb | C++20 | 970b | 2024-07-06 17:10:46 | 2024-07-06 17:10:47 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = double;
constexpr int N = 3e5 + 5;
const ll inf = 1e16;
void solve(){
string s;
cin >> s;
vector<int> cnt(26);
int n = s.size();
if(n == 1){
cout << "YES\n";
cout << s << "\n";
return;
}
for(int i = 0; i < n; ++i){
cnt[s[i] - 'a']++;
}
string ans;
while(ans.size() < n){
for(int i = 0; i < 26; ++i){
if(cnt[i]){
cnt[i]--;
ans += i + 'a';
}
}
}
if(ans[0] == ans[1] || (n > 2 && ans[0] == ans[2])){
cout << "NO\n";
}else{
cout << "YES\n";
cout << ans << "\n";
}
}
int main(void){
ios_base::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int t = 1;
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: 3588kb
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: 3552kb
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)