QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#600029 | #8829. Aibohphobia | xydCatGirl# | WA | 0ms | 3488kb | C++23 | 678b | 2024-09-29 14:14:49 | 2024-09-29 14:14:50 |
Judging History
answer
#include <iostream>
using namespace std;
int main()
{
int t; cin >> t; while (t--) {
string s; cin >> s;
if (size(s) < 2) { cout << "Yes\n" << s << '\n'; }
int d(0), e(0), a[26] = {}; char c;
for (char i : s) ++a[i - 'a'];
for (int i(0); i < 26; ++i) if (a[i]) { if (!e || a[i] < e) c = i + 'a', e = a[i]; ++d; }
if (d < 2 || (e > 1 && d < 3)) { cout << "No\n"; continue; }
s = ""; s.push_back(c); --a[c - 'a'];
for (int i(0); i < 26; ++i) if (i + 'a' ^ c) while (a[i]--) s.push_back(i + 'a');
while (a[c - 'a']--) s.push_back(c);
cout << "Yes\n" << s << '\n';
} return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3488kb
input:
5 a sos abba icpc tenet
output:
Yes a No Yes oss No Yes iccp Yes neett
result:
wrong answer Jury found the answer but participant didn't (test case 2)