-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path1.cpp
More file actions
40 lines (31 loc) · 760 Bytes
/
Copy path1.cpp
File metadata and controls
40 lines (31 loc) · 760 Bytes
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
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string s;
int cnt[27];
int len;
int main() {
cin >> s;
len = s.length();
for (int i = 0; i < len; i++) cnt[s[i] - 'A']++;
int oddN = 0;
for (int i = 0; i < 26; i++)
if (cnt[i] % 2) oddN++;
if (oddN > 1) printf("I'm Sorry Hansoo\n");
else {
string tmp;
for (int i = 0; i < 26; i++)
for (int j = 0; j < cnt[i] / 2; j++) tmp += 'A' + i;
string ans = tmp;
for (int i = 0; i < 26; i++)
if (cnt[i] % 2) {
ans += 'A' + i;
break;
}
reverse(tmp.begin(), tmp.end());
ans += tmp;
cout << ans << endl;
}
return 0;
}