QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#185785 | #2374. Cycle String? | Hanx16Msgr | WA | 3ms | 3708kb | C++14 | 762b | 2023-09-22 16:41:08 | 2023-09-22 16:41:09 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i, a, b) for (int i = (a); i <= (b); ++i)
#define Rof(i, a, b) for (int i = (a); i >= (b); --i)
using namespace std;
using i64 = long long;
constexpr int _N = 1e6 + 5;
string c;
deque<pair<int, int>> q;
int cnt[26];
signed main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> c;
int n = c.length() / 2;
for (char t : c) ++cnt[t - 'a'];
For(i, 0, 25) if (cnt[i])
q.push_back({ i, cnt[i] });
string ans;
while (!q.empty()) {
auto cur = q.front(); q.pop_front();
int cnt = min(n, cur.second);
For(i, 1, cnt)
ans += cur.first + 'a', --cur.second;
if (cur.second) q.push_back(cur);
}
if (ans.front() == ans.back()) cout << "NO\n";
else cout << "YES\n" << ans << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3436kb
input:
cbbabcacbb
output:
YES aabbbbbccc
result:
ok The contestant and jury found an answer
Test #2:
score: 0
Accepted
time: 1ms
memory: 3472kb
input:
aa
output:
NO
result:
ok Solution does not exist
Test #3:
score: 0
Accepted
time: 0ms
memory: 3508kb
input:
afedbc
output:
YES abcdef
result:
ok The contestant and jury found an answer
Test #4:
score: 0
Accepted
time: 1ms
memory: 3448kb
input:
cghfbdae
output:
YES abcdefgh
result:
ok The contestant and jury found an answer
Test #5:
score: 0
Accepted
time: 1ms
memory: 3516kb
input:
babcacca
output:
YES aaabbccc
result:
ok The contestant and jury found an answer
Test #6:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
hfjeacbdgi
output:
YES abcdefghij
result:
ok The contestant and jury found an answer
Test #7:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
fblcmcafgichjocodacanejmiaghclclmpnjcklkelhijghmgkhicdaafkgiaenjefkmmminihdfmiokjghdnohmddmgae
output:
YES aaaaaaaabcccccccccddddddeeeeefffffggggggghhhhhhhhiiiiiiiijjjjjjkkkkkklllllmmmmmmmmmmnnnnnoooop
result:
ok The contestant and jury found an answer
Test #8:
score: 0
Accepted
time: 1ms
memory: 3436kb
input:
babaccacbcacacbcabbcacacbbbbabccbcbaabbbabcbbcacaaccbbbaaacacaccaacabaabaaaabaabbccabcaaacccccabbcbacabccbacabacaccbbabccccabbacccbaacacaccbacababcaccaccacacbaaccbcccaaacaabbacbcbbcccaaaacbbcccccccccaabbcabcbcacbccaababcaaccccaccbcbacaacbaacbbaacbaacbacaaaacaaacbbbaccbabcababaccacacccbcbbcccaaaababa...
output:
YES aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbb...
result:
ok The contestant and jury found an answer
Test #9:
score: 0
Accepted
time: 1ms
memory: 3468kb
input:
ccfaehbdffhadecdgacahfgbbbgcccfhfdbafbadddcgcfdafccdcafhaggeaghchcdegbfcecbhdhefdahddaeadacbachgdcchdcfdbefbbdcadegbefghceehabcaggahfahcgdchdbfhhcdefaadafcgdcfefdhebddhfahehedeefhcbdedafdaggbgggeadecgeefafafedcfgeehbhefhdfgdbebadeefdhhdedbgdfeehfchhfeffdfffghhehfbfegacbehdehcdaadhfhgdbhcaghcccgdcgdd...
output:
YES aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
result:
ok The contestant and jury found an answer
Test #10:
score: 0
Accepted
time: 1ms
memory: 3468kb
input:
ifeehacdbg
output:
YES abcdeefghi
result:
ok The contestant and jury found an answer
Test #11:
score: 0
Accepted
time: 0ms
memory: 3436kb
input:
gwrffzdydmtyficvthjgseannpwxxkaqyrykfbziqszdirlwkqzsvwohmmcaudpyovcnfddsdvvytpdsal
output:
YES aaaabcccddddddddefffffgghhiiijkkkllmmmnnnoopppqqqrrrssssstttuvvvvvwwwwxxyyyyyyzzzz
result:
ok The contestant and jury found an answer
Test #12:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
gbmfhaeabeleiagcllhiiifmchighalckkghajaihiagmclibehjbaegdajebjhfbidahblcbemcdmmjbcdbhbdfldljmffgcbkdmacmjccmbjjmjccbaiiaffegbblbhehfaljdedhmkhldefdhgfgeagdglijediihclkcklcaefdmedkffabfcaliheaiaiagaegejmmddkkedbigkmdammkhemllbckieefclhglhgeabgfffkijjemekmkjggdjehmidbjjjhljdmjkeijaigiffkhfehkekglcaeje...
output:
YES aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee...
result:
ok The contestant and jury found an answer
Test #13:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
pangkaeejgcohrfranglmibbnmldpriqndrjbhqcfdibgjlhedbghhiqcbhafrcpchhdjfakqnikdgpqcghcknnqrgpjjdhnjhbjhljdoorojmfbrrlljmimqfdrojmfldpdmclafhkmidqhalnrikcgmqgcnihorfnbojmfrrflqkmgbpqbieeffjbphrekocrmjjjopojmqahpeqpfkpmhpriarlmgoqmmjhdbpoaaiggpppgnhlfckcndmmklafdpnkgrkrgfhcgfhogghcmiobhgpjeenffmgbjjbdca...
output:
YES aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
result:
ok The contestant and jury found an answer
Test #14:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
output:
NO
result:
ok Solution does not exist
Test #15:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
NO
result:
ok Solution does not exist
Test #16:
score: 0
Accepted
time: 3ms
memory: 3708kb
input:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
NO
result:
ok Solution does not exist
Test #17:
score: 0
Accepted
time: 1ms
memory: 3448kb
input:
baabba
output:
YES aaabbb
result:
ok The contestant and jury found an answer
Test #18:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
aaabbaabbbabbaaabbbbbbbbabaaaaabbababaaaabaaaabbbaababbb
output:
YES aaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbb
result:
ok The contestant and jury found an answer
Test #19:
score: -100
Wrong Answer
time: 0ms
memory: 3516kb
input:
baabaaabaabaabbaaaababbababbababaaabbaabaaabaaaabbbaaabaabaaaabbbbaabbabbabbabaaababbabaabbabbbabaabbabbbbbbbbaaabbabbaaaaaaabaaaaaababaaabbaabbaabaaabaaabbabbbabaaaabbbabaaaaabaababaaabababaababababbbaabababbaaabbbbbaabaabababbaaaabaabbbaababbaabbbaababbbbaaaababbabababbbabbbbabaabaabaabbbbbabbabbb...
output:
NO
result:
wrong answer The contestant did not find a solution while jury did it