QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#577532 | #8829. Aibohphobia | Ycfhnnd | WA | 0ms | 3752kb | C++23 | 1.5kb | 2024-09-20 12:29:22 | 2024-09-20 12:29:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
void solve(){
string s;
cin >> s;
int n = s.size();
if (n == 1){
cout << "YES\n" << s << "\n";
}else if (n == 2){
if (s[0] == s[1]){
cout << "NO\n";
}else{
cout << "YES\n" << s << "\n";
}
}else if(n == 3){
if (s[0] == s[1] and s[1] == s[2]){
cout << "NO\n";
}else{
cout << "YES\n";
sort(s.begin(), s.end());
if (s[0] == s[1]) swap(s[0], s[2]);
cout << s << "\n";
}
}else{
vector<int>cnt(26);
int c1 = 0;
for (auto c : s){
++cnt[c - 'a'];
if(cnt[c - 'a'] == 1){
c1 ++;
}
}
if (c1 < 3){
cout << "NO\n";
}else{
cout << "YES\n";
for (int i = 0;i < 26;i ++){
if (cnt[i]){
cout << char('a' + i);
cnt[i] --;
}
}
for (int i = 0;i < 26;i ++){
while (cnt[i]){
cout << char('a' + i);
cnt[i] --;
}
}
cout << "\n";
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T --){
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3520kb
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: 3752kb
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 uq 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)