poj 2328 Gussing Game

来源:互联网 发布:网络营销软件排行 编辑:程序博客网 时间:2024/06/15 21:04

Description

Stan and Ollie are playing a guessing game. Stan thinks of a number between 1 and 10 and Ollie guesses what the number might be. After each guess, Stan indicates whether Ollie’s guess is too high, too low, or right on.
After playing several rounds, Ollie has become suspicious that Stan cheats; that is, that he changes the number between Ollie’s guesses. To prepare his case against Stan, Ollie has recorded a transcript of several games. You are to determine whether or not each transcript proves that Stan is cheating.

Input

Standard input consists of several transcripts. Each transcript consists of a number of paired guesses and responses. A guess is a line containing single integer between 1 and 10, and a response is a line containing “too high”, “too low”, or “right on”. Each game ends with “right on”. A line containing 0 follows the last transcript.

Output

For each game, output a line “Stan is dishonest” if Stan’s responses are inconsistent with the final guess and response. Otherwise, print “Stan may be honest”.

Sample Input

10
too high
3
too low
4
too high
2
right on
5
too low
7
too high
6
right on
0

Sample Output

Stan is dishonest
Stan may be honest

Source

Waterloo local 2003.07.05

/*Problem: 2328  User: saruka Memory: 680K  Time: 32MS Language: G++  Result: Accepted */#include<cstdio>#include<iostream>#include<cstring>#include<string>using namespace std;inline int getint(){    int r = 0, k = 1;    char c = getchar();    for(; c < '0' || c > '9'; c = getchar())        if(c == '-') k = -1;    for(; c >= '0' && c <= '9'; c = getchar())        r = r * 10 + c - '0';    return r * k;}int n, begin = 0, end = 2147483647, x;char str[10];int main(){    while( cin >> n && n )    {        getchar();        begin = 0, end = 2147483647;         while ( gets(str) && strcmp(str,"right on") )         {            if( strcmp(str,"too high") == 0 && n < end )                end = n;            else                if( strcmp(str,"too low") == 0 && n > begin )                    begin = n;            cin >> n;            getchar();        }        if( n > begin && n < end )            printf("Stan may be honest\n");        else            printf("Stan is dishonest\n");    }     return 0;}

Powered By Saruka.
Copyright © 2016 All Rights Reserved.

0 0
原创粉丝点击