QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#706750 | #8829. Aibohphobia | jiujiu# | WA | 0ms | 3592kb | C++20 | 759b | 2024-11-03 13:17:11 | 2024-11-03 13:17:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
void sovle(){
std::string s;
std::cin >> s;
std::vector<int> c(26);
for(auto i : s){
c[i - 'a']++;
}
std::string ans = "";
while(ans.size() != s.size()){
for(int i = 0; i < 26; i++){
if(c[i]){
c[i]--;
ans += i + 'a';
}
}
}
int flag = 1;
if(s.size() >= 2){
if(ans[0] == ans[1])flag = 0;
}
if(s.size() >= 3){
if(ans[0] == ans[2])flag = 0;
}
if(flag){
std::cout << "YES\n";
std::cout << ans << "\n";
}else{
std::cout << "NO\n";
}
}
signed main(){
std::ios::sync_with_stdio(false),std::cin.tie(0),std::cout.tie(0);
int _ = 1;
std::cin >> _;
while(_--){
sovle();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3484kb
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: 3592kb
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)