QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#460593 | #8829. Aibohphobia | QwertyPi# | WA | 1ms | 3408kb | C++14 | 1.3kb | 2024-07-01 21:18:39 | 2024-07-01 21:18:40 |
Judging History
answer
#include <bits/stdc++.h>
#define all(a) begin(a), end(a)
#define sz(a) (int) (a).size();
using namespace std;
void solve() {
string s; cin >> s;
map<char, int> M;
for (auto c : s) {
M[c]++;
}
if (M.size() == 1) {
cout << "NO" << '\n';
return;
}
if (M.size() == 2) {
bool has_1 = false;
for (auto [c, cc] : M) {
if (cc == 1) has_1 = true;
}
if (!has_1) {
cout << "NO" << '\n';
return;
}
char fi = '\0';
vector<char> C;
for (auto [c, cc] : M) {
C.push_back(c);
}
if (M[C[0]] > 1) swap(C[0], C[1]);
cout << "YES" << '\n';
for (auto c : C) {
for (int j = 0; j < M[c]; j++) {
cout << c;
}
}
cout << '\n';
return;
}
cout << "YES" << '\n';
for (auto [c, cc] : M) {
cout << c;
}
for (auto [c, cc] : M) {
for (int i = 1; i < cc; i++) {
cout << c;
}
}
cout << '\n';
}
int32_t main(){
#ifndef LOCAL
cin.tie(0); cout.tie(0)->sync_with_stdio(false);
#endif
int t; cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3408kb
input:
5 a sos abba icpc tenet
output:
NO YES oss NO YES cipc YES entet
result:
wrong answer Jury found the answer but participant didn't (test case 1)