QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#662783#8829. Aibohphobiadaoqi#WA 0ms3840kbC++201.2kb2024-10-21 10:24:572024-10-21 10:24:58

Judging History

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

  • [2024-10-21 10:24:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3840kb
  • [2024-10-21 10:24:57]
  • 提交

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);
    bool flag = 0;
    for (char c: s) a[c - 'a']++;
    for (int i = 0; i < 26; i++) {
        if (a[i] & 1) flag = 1;
    }
    for (int i = 0; i < 26; i++) {
        if (a[i] == 0 || (a[i] % 2 == 0 && flag)) continue;
        t += char(i + 'a');
        for (int j = 0; j < 26; j++) {
            if (j == i) continue;
            t += std::string(a[j], j + 'a');
        }
        t += std::string(a[i] - 1, i + 'a');
        break;
    }
    int r = t.size() - 1;
    while (r >= 0 && t[r] == t[0]) r--;
    if (r != t.size() - 1) r++;
    for (int l = 0; 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: 3840kb

input:

5
a
sos
abba
icpc
tenet

output:

YES
a
YES
oss
NO
YES
iccp
YES
neett

result:

ok Correct (5 test cases)

Test #2:

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

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
jiit
NO
YES
loo
NO
YES
qu
YES
mggvv
NO
NO
NO
YES
o
YES
ummmm
YES
aetvv
YES
lntx

result:

wrong answer Jury found the answer but participant didn't (test case 14)