Created
July 13, 2019 03:09
-
-
Save surinoel/03141048efd2936537f6c12d9f024543 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int cnt[26]; | |
int main(void) { | |
ios_base::sync_with_stdio(false); | |
cin.tie(nullptr); | |
string s; cin >> s; | |
for (int i = 0; i < s.size(); i++) { | |
cnt[s[i] - 'A'] += 1; | |
} | |
bool ok = true; | |
int countOdd = 0; | |
string odd = ""; | |
for (int i = 0; i < 26; i++) { | |
if (cnt[i] % 2) { | |
countOdd += 1; | |
odd = 'A' + i; | |
} | |
} | |
if (countOdd > 1) { | |
cout << "I'm Sorry Hansoo\n"; | |
return 0; | |
} | |
string ans = ""; | |
for (int i = 0; i < 26; i++) { | |
for (int j = 0; j < cnt[i] / 2; j++) { | |
ans += 'A' + i; | |
} | |
} | |
string retmp = ans; | |
reverse(retmp.begin(), retmp.end()); | |
cout << ans + odd + retmp << '\n'; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment