-
Notifications
You must be signed in to change notification settings - Fork 0
/
1213.cpp
47 lines (41 loc) · 968 Bytes
/
1213.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int alpha[26];
int main(){
string name; cin >> name;
for (int i=0; i<name.size(); i++)
alpha[name[i] - 'A']++;
int err = 0;
int index = -1;
for (int i=0; i<26; i++){
if (alpha[i] > 0){
if (alpha[i] % 2 == 1){
index = i;
alpha[i]--;
err++;
}
}
}
if (err>1)
printf("I'm Sorry Hansoo\n");
else {
string ans = "";
string temp = "";
for (int i = 0; i < 26; i++) {
if (alpha[i] > 0) {
for (int j = 0; j < alpha[i] / 2; j++) {
ans += i + 'A';
}
}
}
temp = ans;
reverse(temp.begin(), temp.end());
if (index != -1) {
ans += index + 'A';
}
ans += temp;
cout << ans << '\n';
}
}