-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path276B-LittleGirlAndGame.cpp
54 lines (52 loc) · 1.13 KB
/
276B-LittleGirlAndGame.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
48
49
50
51
52
53
54
#include<bits/stdc++.h>
using namespace std;
bool ispalindrome_possible(string s){
sort(s.begin(),s.end());
if(s.length()&1){
bool odd=0;
int c=0;
int l=0;
int r=0;
while(r<s.length()){
if(s[l] == s[r]) c++,r++;
else{
if(!odd && c&1) odd=1;
else if(odd && c&1) return false;
c=0;
l=r;
}
}
}
else{
int c=0;
int l=0;
int r=0;
while(r<s.length()){
if(s[l] == s[r]) c++,r++;
else{
if(c&1) return false;
c=0;
l=r;
}
}
}
return true;
}
int main(){
string s;
cin>>s;
bool c=0;
while(!ispalindrome_possible(s)){
string temp ="";
bool removed_one=0;
for(auto i:s) {
if(temp.find(i) == -1 || removed_one) temp.push_back(i);
else removed_one=1;
}
if(temp.length() == s.length()) temp.pop_back();
s = temp;
c=!c;
}
if(!c) cout<<"First";
else cout<<"Second";
}