QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#558962#8829. Aibohphobiasnow#WA 0ms3680kbC++231.9kb2024-09-11 19:28:472024-09-11 19:28:51

Judging History

你现在查看的是最新测评结果

  • [2024-09-11 19:28:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3680kb
  • [2024-09-11 19:28:47]
  • 提交

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)