水题,谨记有26个英文字母!!!
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
typedef long long ll;
const int maxn = 2e5 + 5;
using namespace std;
int main() {
char s[maxn];
memset(s, 0, sizeof(s));
scanf("%s", s);
int n = strlen(s), idx[26] = { 0 }, t;
for (int i = 0; i < n; i++) idx[s[i] - 97]++;
for (int i = 25; i >= 0; i--) if (idx[i] & 1)
for (int j = 0; j < i; j++) if (idx[j] & 1) {
idx[j]++; idx[i]--;
break;
}
for (int i = 0; i < 26; i++) {
if (idx[i] & 1) {
s[n / 2] = i + 97;
idx[i]--;
}
while (idx[i] > 0) {
s[t] = s[n - 1 - t] = i + 97;
idx[i] -= 2; t++;
}
}
printf("%s\n", s);
}