QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#559010 | #8829. Aibohphobia | clearlove13# | WA | 0ms | 3624kb | C++23 | 1.6kb | 2024-09-11 19:39:36 | 2024-09-11 19:39:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ull = unsigned long long;
#define ff(x) fixed << setprecision(x)
#define vel vector<long long>
#define vei vector<int>
#define ves vector<string>
#define asn ans
constexpr int inf = 0x3f3f3f3f;
constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr db EPS = 1.0e-9;
constexpr ll MOD = 998244353LL;
constexpr ll SZ = 1e6;
constexpr ll MAXN5 = 2e5 + 5;
constexpr ll MAXN6 = 2e6 + 5;
ll n, m;
ll ch[26];
void Solve(void) {
string s;
cin >> s;
fill(ch, ch + 26, 0);
// cout<<s;
for (auto c : s) {
ch[c - 'a']++;
}
vector<pair<ll, char>> v;
for (int i = 0; i < 26; i++) {
if (ch[i] != 0) {
v.push_back({ch[i], char('a' + i)});
}
}
sort(v.begin(), v.end());
string ans;
for (int i = 1; i < v.size(); i++) {
for (int j = 0; j < v[i].first; j++) {
ans = ans + v[i].second;
}
}
for (int i = 1; i < v[0].first; i++) {
ans = ans + v[0].second;
}
ans = v[0].second + ans;
string ans1 = ans;
reverse(ans.begin(), ans.end());
if (ans == ans1 && ans.size() != 1) {
cout << "NO" << '\n';
} else {
cout << "YES" << '\n';
cout << ans1 << '\n';
}
}
int main(void) {
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
// freopen("mine.in", "r", stdin);
// freopen("mine.out", "w", stdout);
int cas = 1;
cin >> cas;
while (cas--)
Solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
5 a sos abba icpc tenet
output:
YES a YES oss NO YES ipcc YES neett
result:
ok Correct (5 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3620kb
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 jvttt NO YES elnpv YES jtii NO YES loo NO YES qu YES mggvv NO NO YES ykkk YES o YES ummmm YES aetvv YES lntx
result:
ok Correct (18 test cases)
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3552kb
input:
138 gcseqpht brrrzsrerr ree lgryyyh wbxkwwwwx hsihaga kvvslzgv dssd qhrqqqrqyh dfffffsfgf ssuzuuzzs rrwnyrcdnb ealelecu ccfwwwccwc emeieme xeexeswes ymkkkkpkk eimderoz lflllh lluylcll rquqrqu mllmllll cscscc ssssssssss cn llljlzlzj h kbbxahczit yxrrrrxlkr uikiakika tntnnqntw sjhxyfsy fcyyyf dbvbvdbw...
output:
YES ceghpqst YES beszrrrrrr YES ree YES ghlryyy YES bkxxwwwww YES gisaahh YES gklszvvv NO YES yhhrrqqqqq YES dgsfffffff YES suuuzzzss YES bcdwynnrrr YES aculleee YES fwwwwccccc YES immeeee YES wssxxeeee YES mpykkkkkk YES dimorzee YES fhllll YES cuylllll YES ruuqqqr NO NO NO YES cn YES jzzlllllj YES ...
result:
wrong answer Some prefix is a palindrome (test case 38)