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. 11 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. 11 months ago
    2025-12-19 13:41:04

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

  3. 10 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. 9 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. 9 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. 9 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. 8 months 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. 8 months 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. 8 months 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

  10. 2 months ago
    2026-9-07 9:13:07

    One of the best online casino experiences I have had recently. The graphics are crisp and the gameplay is very fair. 1cassinoonline

  11. 2 months ago
    2026-9-16 7:32:12

    Best gaming experience I’ve had in a while. The graphics are crisp and the wins feel fair. You should give phpisoking a try if you like excitement.

  12. 1 month ago
    2026-9-25 23:57:31

    If you love slots then this is the place to be. The graphics are great and the jackpot hits are actually happening. Don’t miss out on bosku777slot.

  13. 3 weeks ago
    2026-10-12 23:39:21

    I’ve tried many platforms but this one is really smooth. The payouts are fast and the games are super exciting. Definitely a great choice for locals! phpjiliph

  14. 1 week ago
    2026-10-24 16:38:23

    The atmospheric design and unique bonus rounds make this my absolute favorite place to unwind. I appreciate how they focus on gameplay quality over flashy tricks. A dark themed escape that somehow feels surprisingly bright and welcoming. The math models are fair and the support staff responds faster than I expected during my first session. Discover the magic for yourself at dark168slot

  15. 5 days ago
    2026-10-27 15:11:38

    Such a fun way to spend my free time. The games are fair and the rewards keep me coming back for more. Go check out 6jiligames now.

Send Comment Edit Comment


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