Wednesday, June 29, 2016

UVa 10530 Guessing Game

#include <bits/stdc++.h>
#define LL long long
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REV(i,n) for(int i=n-1;i>=0;i--)
#define pri(a) cout << a << endl;
#define prii(a,b) cout << a << " " << b << endl;
using namespace std;

int main()
{
    int n;
    vector <int> th, tl;
    string s;

    while(cin>>n)
    {
        if(n==0) return 0;

        cin.ignore();
        getline(cin,s);

        if(s=="too low")
        {
            tl.push_back(n);
        }
        else if(s=="too high")
        {
            th.push_back(n);
        }
        else
        {
            bool fl = false;

            REP(i,SZ(tl))
            {
                if(n<=tl[i]){fl=true; break;}
            }
            REP(i,SZ(th))
            {
                if(n>=th[i]){fl=true; break;}
            }

            if(fl) puts("Stan is dishonest");
            else puts("Stan may be honest");

            tl.clear(); th.clear();
        }
    }
    return 0;
}

No comments:

Post a Comment