POJ 2328 Guessing Game

来源:互联网 发布:淘宝网店域名怎么改 编辑:程序博客网 时间:2024/05/10 07:08

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

10too high3too low4too high2right on5too low7too high6right on0

Sample Output

Stan is dishonest

Stan may be honest

#include<cstdio>#include<iostream>#include<cstring>#include<map>#include<queue>#include<stack>#include<algorithm>#include<cmath>#include<string>using namespace std;const int maxn=100005;int tot,n;int a[maxn],b[maxn];string s1,s2;int main(){tot=0;while (cin>>n,n){cin>>s1>>s2;if (s1=="right"){int flag=1;for (int i=0;i<tot;i++){if (b[i]==-1&&a[i]>=n) flag=0;if (b[i]==1&&a[i]<=n) flag=0;}if (flag) printf("Stan may be honest\n");else printf("Stan is dishonest\n");tot=0;}else {a[tot]=n;if (s2=="low") b[tot++]=-1;else b[tot++]=1;}}return 0;}


0 0
原创粉丝点击