forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.cpp
More file actions
33 lines (28 loc) · 627 Bytes
/
A.cpp
File metadata and controls
33 lines (28 loc) · 627 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
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define TWO(x) (1<<(x))
#define CONTAIN(S,x) (S & TWO(x))
string s, res;
bool palin(string s) {
for(int i = 0; i < s.length(); i++)
if (s[i] != s[s.length()-i-1]) return false;
return true;
}
void update(string cur) {
if (!palin(cur)) return ;
if (cur > res) res = cur;
}
int main() {
cin >> s;
int n = s.length();
for(int mask = 0; mask < TWO(n); ++mask) {
string cur = "";
for(int i = 0; i < n; i++)
if (CONTAIN(mask,i)) cur = cur + s[i];
update(cur);
}
cout << res << endl;
return 0;
}