// compile: g++ -o data data.cpp -std=gnu++20 -DLOCAL
// run: ./data < data.in
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifdef LOCAL
#endif
#define sz(v) ((int)(v).size())
#define PV(v) for (int i=0;i<v.size();++i)cout<<v[i]<<" ";cout<<endl;
#define INTINF 9223372036854775807
#define int long long
using namespace std;
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
string s; cin >> s;
vector<int> h(26, 0);
int n = s.length();
for (int i = 0; i < n; ++i) ++h[s[i] - 'A'];
int oddind = -1, odd = 0;
for (int i = 0; i < 26; ++i) {
if (h[i] & 1) {
++odd;
oddind = i;
}
}
if ((!(n & 1) && odd) || (n & 1 && odd > 1)) {
cout << "NO SOLUTION" << endl;
return 0;
}
for (int i = 0; i < 26; ++i) {
if (i == oddind) continue;
for (int j = 0; j < (h[i]>>1); ++j) cout << char(i + 'A');
}
if (~oddind) for (int j = 0; j < h[oddind]; ++j) cout << char(oddind + 'A');
for (int i = 25; i >= 0; --i) {
if (i == oddind) continue;
for (int j = 0; j < (h[i]>>1); ++j) cout << char(i + 'A');
}
cout << endl;
return 0;
}
No Comments