Uva 10530 Solution

#include<bits/stdc++.h>
#define p pair<int, string>
using namespace std;
vector<p>v;
int main()
{
    string s;
    int n, i;
    
    while(cin >> n && n != 0)
    {
        getchar();
        getline(cin, s);
        v.push_back(p(n, s));
        while(s != "right on")
        {
            cin >> n;
            getchar();
            getline(cin, s);
            v.push_back(p(n, s));
        }
        int m = v.size() - 1;

        int j = v[m].first, f = 1;

        for(i=0;i<m;i++)
        {
            if(j < v[i].first && v[i].second == "too low")
            {
                f = 0;
                break;
            }
            else if(j > v[i].first && v[i].second == "too high")
            {
                f = 0;
                break;
            }
            else if(j == v[i].first && v[i].second != "right on")
            {
                f = 0;
                break;
            }
        }

        if(f == 1)
            cout << "Stan may be honest" << "\n";
        else
            cout << "Stan is dishonest" << "\n";

        v.clear();
    }

    return 0;
}

Comments