Tuesday, 11 August 2015

UVA 489 Hangman Judge

///     Raihan Ruhin
///     CSE, Jahangirnagar University.
///     Dhaka-Bangladesh.
///     id: raihanruhin (topcoder / codeforces / codechef / hackerrank / uva / uvalive / spoj), 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


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int tc, kk=1, n, arr[30];
    string s, s2;
    char ch;
    while(cin>>n)
    {
        if(n==-1) return 0;
        cin>>s>>s2;
        CLR(arr);
        int wa=0;
        for(int i=0;i<s.size();i++)
            arr[ s[i]-'a' ] = 1;
        cout<<"Round "<<n<<"\n";
        bool chk=false;
        for(int i=0;i<s2.size();i++)
        {
            if(arr[ s2[i]-'a'])
                arr[ s2[i]-'a']=0;
            else wa++;
            bool complete=true;
            for(int j=0;j<26;j++)
                if(arr[j])
                    complete=false;
            if(complete)
            {
                cout<<"You win.\n";
                chk=true;
                break;
            }
            if(wa==7)
            {
                cout<<"You lose.\n";
                break;
            }
        }
        if(!chk && wa<7)
        cout<<"You chickened out.\n";
    }
return 0;
}

No comments:

Post a Comment