CSES Palindrome Reorder
// 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;
}

Comments

  1. 4 months ago
    2025-12-06 2:26:07

    VNL Casino, a friend told me that this casino is very popular in the local area. I personally haven’t tried it yet, but you can try it now. Find out more: vnlcasino

  2. 3 months ago
    2025-12-19 13:41:04

    11betcon – not a bad option to see some promotions and events. Check them here:11betcon!

  3. 3 months ago
    2025-12-29 6:09:19

    Medusa! Mythological slots at its finest. This version is really well-done, with smooth animations and exciting bonus features. If you’re into Greek mythology and slots, medusagamevn is worth a look!

  4. 2 months ago
    2026-1-24 23:42:30

    Been playing at phdreamonlinecasino for a while now. Pretty good selection of games and the payouts are decent. Give it a shot! Check phdreamonlinecasino!

  5. 2 months ago
    2026-1-24 23:42:46

    Need help with the big88login sometimes it’s a bit slow! Anyone else have this issue? Anyway hope all you win soon! Easy access at big88login!

  6. 2 months ago
    2026-1-24 23:43:01

    Jiliwin11, huh? Sounds like a potentially fun time. Might have to give it a shot and see what it’s all about! Explore it yourself: jiliwin11

  7. 2 weeks ago
    2026-3-03 21:40:28

    Alright, Playkaro247 is where it’s at for quick gaming fixes. Easy to log in and hop right into the action. Totally worth checking out. playkaro247

  8. 2 weeks ago
    2026-3-03 21:40:44

    78wind, hey, not bad! Gave it a spin and had some decent luck. Nothing crazy, but kept me entertained for a while. I’d say it’s worth checking out if you’re looking for something new. Happy gaming! Click here for 78wind

  9. 2 weeks ago
    2026-3-03 21:41:00

    Alright, alright, arenapluspc. Gave this a shot after seeing it pop up everywhere. Interface is pretty slick and the variety of options is solid. Think I’ll be back, especially if they keep the promos coming! Find out more arenapluspc

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
Previous
Next