QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#197371 | #2374. Cycle String? | black_ice | WA | 1ms | 3704kb | C++20 | 1.0kb | 2023-10-02 15:12:15 | 2023-10-02 15:12:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define ull unsigned long long
int T,n,m;
const int N = 1010,INF = 1e9;
string s;
int cnt[N];
void solve()
{
cin >> s;
n = s.size();
for(int i = 0;i < n;i++)
{
cnt[s[i] - 'a']++;
}
int flag = -1;
for(int i = 0;i < 26;i++)
{
if(cnt[i] > n / 2)
{
flag = i;
break;
}
}
if(flag == -1)
{
cout << "YES" << endl;
sort(s.begin(),s.end());
cout << s << endl;
return ;
}
bool tmp = true;
for(int i = 0;i < 26;i++)
{
if(i == flag) continue;
if(cnt[i] >= 2)
{
tmp = false;
break;
}
}
if(tmp)
{
cout << "NO" << endl;
return ;
}
sort(s.begin(),s.end());
cout << "YES" << endl;
s.insert(s.begin() + n / 2,s[n - 1]);
s.erase(prev(s.end()));
cout << s << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
T = 1;
while(T--)
{
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3444kb
input:
cbbabcacbb
output:
YES aabbbbbccc
result:
ok The contestant and jury found an answer
Test #2:
score: 0
Accepted
time: 1ms
memory: 3448kb
input:
aa
output:
NO
result:
ok Solution does not exist
Test #3:
score: 0
Accepted
time: 0ms
memory: 3452kb
input:
afedbc
output:
YES abcdef
result:
ok The contestant and jury found an answer
Test #4:
score: 0
Accepted
time: 0ms
memory: 3460kb
input:
cghfbdae
output:
YES abcdefgh
result:
ok The contestant and jury found an answer
Test #5:
score: 0
Accepted
time: 1ms
memory: 3452kb
input:
babcacca
output:
YES aaabbccc
result:
ok The contestant and jury found an answer
Test #6:
score: 0
Accepted
time: 1ms
memory: 3436kb
input:
hfjeacbdgi
output:
YES abcdefghij
result:
ok The contestant and jury found an answer
Test #7:
score: 0
Accepted
time: 1ms
memory: 3452kb
input:
fblcmcafgichjocodacanejmiaghclclmpnjcklkelhijghmgkhicdaafkgiaenjefkmmminihdfmiokjghdnohmddmgae
output:
YES aaaaaaaabcccccccccddddddeeeeefffffggggggghhhhhhhhiiiiiiiijjjjjjkkkkkklllllmmmmmmmmmmnnnnnoooop
result:
ok The contestant and jury found an answer
Test #8:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
babaccacbcacacbcabbcacacbbbbabccbcbaabbbabcbbcacaaccbbbaaacacaccaacabaabaaaabaabbccabcaaacccccabbcbacabccbacabacaccbbabccccabbacccbaacacaccbacababcaccaccacacbaaccbcccaaacaabbacbcbbcccaaaacbbcccccccccaabbcabcbcacbccaababcaaccccaccbcbacaacbaacbbaacbaacbacaaaacaaacbbbaccbabcababaccacacccbcbbcccaaaababa...
output:
YES aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbb...
result:
ok The contestant and jury found an answer
Test #9:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
ccfaehbdffhadecdgacahfgbbbgcccfhfdbafbadddcgcfdafccdcafhaggeaghchcdegbfcecbhdhefdahddaeadacbachgdcchdcfdbefbbdcadegbefghceehabcaggahfahcgdchdbfhhcdefaadafcgdcfefdhebddhfahehedeefhcbdedafdaggbgggeadecgeefafafedcfgeehbhefhdfgdbebadeefdhhdedbgdfeehfchhfeffdfffghhehfbfegacbehdehcdaadhfhgdbhcaghcccgdcgdd...
output:
YES aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
result:
ok The contestant and jury found an answer
Test #10:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
ifeehacdbg
output:
YES abcdeefghi
result:
ok The contestant and jury found an answer
Test #11:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
gwrffzdydmtyficvthjgseannpwxxkaqyrykfbziqszdirlwkqzsvwohmmcaudpyovcnfddsdvvytpdsal
output:
YES aaaabcccddddddddefffffgghhiiijkkkllmmmnnnoopppqqqrrrssssstttuvvvvvwwwwxxyyyyyyzzzz
result:
ok The contestant and jury found an answer
Test #12:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
gbmfhaeabeleiagcllhiiifmchighalckkghajaihiagmclibehjbaegdajebjhfbidahblcbemcdmmjbcdbhbdfldljmffgcbkdmacmjccmbjjmjccbaiiaffegbblbhehfaljdedhmkhldefdhgfgeagdglijediihclkcklcaefdmedkffabfcaliheaiaiagaegejmmddkkedbigkmdammkhemllbckieefclhglhgeabgfffkijjemekmkjggdjehmidbjjjhljdmjkeijaigiffkhfehkekglcaeje...
output:
YES aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee...
result:
ok The contestant and jury found an answer
Test #13:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
pangkaeejgcohrfranglmibbnmldpriqndrjbhqcfdibgjlhedbghhiqcbhafrcpchhdjfakqnikdgpqcghcknnqrgpjjdhnjhbjhljdoorojmfbrrlljmimqfdrojmfldpdmclafhkmidqhalnrikcgmqgcnihorfnbojmfrrflqkmgbpqbieeffjbphrekocrmjjjopojmqahpeqpfkpmhpriarlmgoqmmjhdbpoaaiggpppgnhlfckcndmmklafdpnkgrkrgfhcgfhogghcmiobhgpjeenffmgbjjbdca...
output:
YES aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
result:
ok The contestant and jury found an answer
Test #14:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
output:
NO
result:
ok Solution does not exist
Test #15:
score: 0
Accepted
time: 1ms
memory: 3564kb
input:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
NO
result:
ok Solution does not exist
Test #16:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
NO
result:
ok Solution does not exist
Test #17:
score: 0
Accepted
time: 0ms
memory: 3440kb
input:
baabba
output:
YES aaabbb
result:
ok The contestant and jury found an answer
Test #18:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
aaabbaabbbabbaaabbbbbbbbabaaaaabbababaaaabaaaabbbaababbb
output:
YES aaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbb
result:
ok The contestant and jury found an answer
Test #19:
score: 0
Accepted
time: 0ms
memory: 3376kb
input:
baabaaabaabaabbaaaababbababbababaaabbaabaaabaaaabbbaaabaabaaaabbbbaabbabbabbabaaababbabaabbabbbabaabbabbbbbbbbaaabbabbaaaaaaabaaaaaababaaabbaabbaabaaabaaabbabbbabaaaabbbabaaaaabaababaaabababaababababbbaabababbaaabbbbbaabaabababbaaaabaabbbaababbaabbbaababbbbaaaababbabababbbabbbbabaabaabaabbbbbabbabbb...
output:
YES aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
result:
ok The contestant and jury found an answer
Test #20:
score: -100
Wrong Answer
time: 0ms
memory: 3576kb
input:
bbbaaabbbaaabbaabababbababbbaaaababbbaaabaababaabbaaababbbabbbababbbbbabbabbabaaabbababababbaabaabbbabbababbaabbabaabbaabbbabaaaaabbabbbbbababaaaaabbbbbabaaabbaabaaabbababbabaaaaaaaaabbaabbaaababbabbaababbabbabbabbbaaaaaabbababbabbbbbaaaaabbbabbbbaaaaaaababbabaaaabaabbbbaaaaaababaabaababbbbbbabaabaa...
output:
YES aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
result:
wrong answer There are two equal substrings