QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#662779#8829. Aibohphobiadaoqi#WA 0ms3596kbC++20978b2024-10-21 10:18:542024-10-21 10:18:54

Judging History

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

  • [2024-10-21 10:18:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3596kb
  • [2024-10-21 10:18:54]
  • 提交

answer

#include<bits/stdc++.h>

using i64 = long long;
using l64 = long double;

void DAOQI() {
    std::string s, t;
    std::cin >> s;
    if (s.size() == 1) {
        std::cout << "YES\n";
        std::cout << s << "\n";
        return;
    }
    std::vector<int> a(26);
    for (char c: s) a[c - 'a']++;
    for (int i = 0; i < 26; i++) {
        if (a[i] == 0) continue;
        t += char(i + 'a');
        for (int j = i + 1; j < 26; j++) {
            t += std::string(a[j], j + 'a');
        }
        t += std::string(a[i] - 1, i + 'a');
        break;
    }
    for (int l = 0, r = t.size() - 1; l < r; l++, r--) {
        if (t[l] != t[r]) {
            std::cout << "YES\n";
            std::cout << t << "\n";
            return;
        }
    }
    std::cout << "NO\n";
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int T = 1;
    std::cin >> T;
    while (T--) DAOQI();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3532kb

input:

5
a
sos
abba
icpc
tenet

output:

YES
a
YES
oss
NO
YES
cipc
YES
entte

result:

ok Correct (5 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3596kb

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
jtttv
NO
YES
elnpv
YES
ijti
NO
YES
loo
NO
YES
qu
YES
gmvvg
NO
NO
YES
kykk
YES
o
YES
mummm
YES
aetvv
YES
lntx

result:

wrong answer Some prefix is a palindrome (test case 14)