QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#558962 | #8829. Aibohphobia | snow# | WA | 0ms | 3680kb | C++23 | 1.9kb | 2024-09-11 19:28:47 | 2024-09-11 19:28:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void)
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll t;
cin >> t;
while (t--)
{
string s;
cin >> s;
ll len = s.size();
if (len == 1)
cout << "YES\n"
<< s << '\n';
else
{
map<char, ll> mp;
s = ' ' + s;
ll maxx = 0;
char c;
for (ll i = 1; i <= len; i++)
{
mp[s[i]]++;
}
if (mp.size() >= 3)
{
cout << "YES\n";
for (auto i : mp)
{
cout << i.first;
mp[i.first]--;
}
for (auto i : mp)
{
while (i.second != 0)
{
cout << i.first;
i.second--;
}
}
cout << '\n';
}
else
{
ll flag = 0;
for (auto i : mp)
{
if (i.second == 1)
{
flag = 1;
cout << "YES\n";
cout << i.first;
mp[i.first]--;
}
}
if (flag)
{
for (auto i : mp)
{
while (i.second)
{
cout << i.first;
i.second--;
}
}
cout << '\n';
}
else
{
cout << "NO\n";
}
}
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3652kb
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: 3680kb
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 qYES u YES gmvgv NO NO YES ykkk YES o YES ummmm YES aetvv YES lntx
result:
wrong answer Not a permutation (test case 10)