2 solutions

  • 0
    @ 2026-2-23 16:30:24

    #include #include #include using namespace std;

    int main() { string s; cin >> s; vector cnt(26, 0); for (char c : s) { cnt[c - 'A']++; }
    int odd_count = 0; char odd_char = 0; for (int i = 0; i < 26; i++) { if (cnt[i] % 2 == 1) { odd_count++; odd_char = 'A' + i; } }

    if (odd_count > 1) {
        cout << "NO SOLUTION" << endl;
        return 0;
    }
    string half = "";
    for (int i = 0; i < 26; i++) {
        half += string(cnt[i] / 2, 'A' + i);
    }
    string middle = "";
    if (odd_count == 1) {
        middle = odd_char;
    }
    string result = half + middle;
    
    for (int i = half.length() - 1; i >= 0; i--) {
        result += half[i];
    }
    
    cout << result << endl;
    
    return 0;
    

    }

    Information

    ID
    4625
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    7
    Tags
    # Submissions
    191
    Accepted
    51
    Uploaded By