Codeforces Little Girl and Game

/*
Lionel Messi is such a player that you may catch him, you may touch him, you may feel him
and definitely you may Love him.
Lionel Messi is Messi. A little Magician in this World.

*/

#include<bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(0)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back

typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef map<char, int>mpci;

const int mod = 1000007;
const int high = 100;

int main()
{
    fast;
    string s ;
    int i , len , cnt=0;
    mpci mp;
    while(cin >> s)
    {
        mp.clear();

        len = s.length();

        cnt=0;

        for(i=0; i<len; i++)
        {
            mp[s[i]]++;
        }

        for(char c='a'; c<='z'; c++)
        {
            cnt+=(mp[c] % 2); // The palindrome can be created when the character appearing odd times is 0 or 1.
        }

        if(cnt == 0 or cnt & 1) cout << "First\n";
        else cout << "Second\n";
    }

    return 0;
}

Comments

Popular posts from this blog

SPOJ-CMG - Collecting Mango

LightOJ 1009 - Back to Underworld

LeetCode Palindrome Number