POJ 2328 Guessing Game

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 14681   Accepted: 5153

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

CODE:
#include <iostream>
#include <cstdio>
#include <cstring>
#define REP(i, s, n) for(int i = s; i <= n; i ++)
#define REP_(i, s, n) for(int i = n; i >= s; i --)

using namespace std;

int main(){
    int num; char s[10];
    bool check[15];
    memset(check, 1, sizeof(check));
    while(scanf("%d", &num) != EOF){
        if(num == 0) break;
        scanf("%s", s + 1);
        int ls = strlen(s + 1);
        if(s[ls] == 'n'){
            if(check[num]) printf("Stan may be honest\n");
            else printf("Stan is dishonest\n");
            memset(check, 1, sizeof(check));
        }
        else if(s[ls] == 'h')
            REP(i, num, 10) check[i] = 0;
        else if(s[ls] == 'w')
            REP(i, 1, num) check[i] = 0;
    }
    return 0;
}

 

 
posted @ 2015-05-28 10:13  ALXPCUN  阅读(211)  评论(0编辑  收藏  举报