-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1213.cpp
More file actions
55 lines (52 loc) · 790 Bytes
/
1213.cpp
File metadata and controls
55 lines (52 loc) · 790 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// 1213. 팰린드롬 만들기
// 2019.05.14
// 브루트 포스, 정렬
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
using namespace std;
int arr[26];
int main()
{
string s;
cin >> s;
for (int i = 0; i < s.size(); i++)
{
arr[s[i] - 'A']++;
}
int odd = -1;
for (int i = 0; i < 26; i++)
{
if (arr[i] % 2 == 1 && odd != -1)
{
cout << "I'm Sorry Hansoo" << endl;
return 0;
}
else if (arr[i] % 2 == 1 && odd==-1)
{
odd = i;
}
}
deque<char> dq;
if (odd != -1)
{
dq.push_back(odd + 'A');
arr[odd]--;
}
for (int i = 25; i >= 0; i--)
{
while (arr[i] > 0)
{
dq.push_back(i + 'A');
dq.push_front(i + 'A');
arr[i] -= 2;
}
}
for (int i = 0; i < dq.size(); i++)
{
cout << dq[i];
}
cout << endl;
return 0;
}