Guessing Game

电玩女神 2022-08-01 01:30 194阅读 0赞

Problem F: Guessing Game

Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 20 Solved: 6
[ Submit][ Status][ Web Board]

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.

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.

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”.

Input

Output

Sample Input

  1. 10
  2. too high
  3. 3
  4. too low
  5. 4
  6. too high
  7. 2
  8. right on
  9. 5
  10. too low
  11. 7
  12. too high
  13. 6
  14. right on
  15. 0

Sample Output

  1. Stan is dishonest
  2. Stan may be honest

HINT

  1. #include<cstdio>
  2. #include<cstring>
  3. #include<iostream>
  4. using namespace std;
  5. int main()
  6. {
  7. int n,mx,mn,flag;
  8. char s[30];
  9. flag=0;
  10. mx=11;mn=-1;
  11. while(scanf("%d",&n)&&n)
  12. {
  13. getchar();
  14. gets(s);
  15. if(strcmp(s,"right on")==0)
  16. {
  17. if(flag==0&&n<mx&&n>mn)
  18. {
  19. cout<<"Stan may be honest"<<endl;
  20. }
  21. else
  22. {
  23. cout<<"Stan is dishonest"<<endl;
  24. }
  25. mx=11;
  26. mn=-1;
  27. flag=0;
  28. }
  29. if(strcmp(s,"too high")==0)
  30. {
  31. if(n<=mn)
  32. {
  33. flag=1;
  34. }
  35. else if(n<mx)
  36. {
  37. mx=n;
  38. }
  39. }
  40. if(strcmp(s,"too low")==0)
  41. {
  42. if(n>=mx)
  43. {
  44. flag=1;
  45. }
  46. else if(n>mn)
  47. {
  48. mn=n;
  49. }
  50. }
  51. }
  52. }

发表评论

表情:
评论列表 (有 0 条评论,194人围观)

还没有评论,来说两句吧...

相关阅读

    相关 New Game

    New Game Description New game是在一个M\M的特殊棋盘(棋盘的第i行都标上了数字i)上进行的新式游戏。给定一个数字N,要求选手把一个棋子从

    相关 uva 1612——Guess

    题意:有n个选手参加比赛,比赛有3个题目,每个选手每个题目都有一个评测之前的于得分,当通过题目时才可以得到相应分数,否则为0,然后按照得分排名,id小的排在前面,现在