Sunday, 10 July 2016

Google APAC 2017 University Test Round A Problem A. Country Leader

///     Raihan Ruhin
///     CSE, Jahangirnagar University.
///     Dhaka-Bangladesh.
///     id: raihanruhin (topcoder / codeforces / codechef / uva ), 3235 (lightoj)
///     mail: raihanruhin@ (yahoo / gmail / facebook)
///     blog: ruhinraihan.blogspot.com

#include<bits/stdc++.h>
using namespace std;

#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define PI acos(-1.0)

#define MOD 1000000007
#define MX 100010

#define READ freopen("A-large.in", "r", stdin)
#define WRITE freopen("output.txt", "w", stdout)

int main()
{
    READ;
    WRITE;
    ios_base::sync_with_stdio(0);cin.tie(0);
    int tc,kk=1, n, taken[30];
    string s;
    cin>>tc;
    while(tc--)
    {
        cin>>n;
        getline(cin, s);

        vector< pair< int, string> >  v;

        for(int i=0;i<n;i++)
        {
            int cnt=0;
            CLR(taken);
            getline(cin, s);
            int l=s.size();
            for(int j=0;j<l;j++)
                if(isalpha(s[j]))
                    if(taken[s[j]-'A']==0)
                    {
                        taken[s[j]-'A']++;
                        cnt++;
                    }
            //cout<<s<<" "<<cnt<<endl;
            v.push_back(make_pair(102-cnt, s));
        }
        sort(v.begin(), v.end());
        cout<<"Case #"<<kk++<<": "<< v[0].second <<"\n";
    }
    return 0;
}

No comments:

Post a Comment