第一次训练赛-B

B - 小学生的游戏

FZU - 1575

某天,无聊的小斌叫上几个同学玩游戏,其中有比较笨的小兴,比较傻的小雪,可爱的小霞和自以为是的小楠。他们去找聪明的小明去给他们当裁判。判定谁取得游戏胜利。

而这个游戏是由小斌想个1到10000000的数字让大家猜,看谁先猜中。为了防止小斌作弊,小明记录下了游戏的整个过程。你的任务是判断小斌是否有作弊。

Input

输入数据包括多盘游戏。一次猜数包含两行,第一行是一个数字n(1<=n<=10000000),表示所猜数字。第二行是小斌的回答为"too high","too low","right on"三种答案之一。每盘游戏结束于"right on"。当n=0的时候,整个游戏结束。

Output

对于每盘游戏,若小斌确有撒谎,请输出一行"The guy is dishonest",否则请输出"The guy 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

The guy is dishonest
The guy may be honest

感觉心不在焉,这题都错了半天,拿着答案往回比就行了。


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

bool eq(char *a,char *b);

char a[15],b[]="too low",rt[]="right on";
int num;

struct game{
    bool status;
    int num;
    game(char *a, int n) {
        status = eq(a,b);
        num = n;
    }
};
stack<game> s;
bool check() {
    while (!s.empty()) {
        if ( (s.top().num<num) != s.top().status || s.top().num==num)
            return false;
        s.pop();
    }
    return true;
}

bool eq(char *a, char *b) {
    while (*a && *a==*b){a++;b++;}
    return *a==*b;
}

int main()
{
    while (~scanf("%d",&num) && num) {
        scanf("%c",a);
        
        cin.getline(a,15);
        if (eq(a,rt)) {
            printf(check()?"The guy may be honest\n":"The guy is dishonest\n");
            while (!s.empty())s.pop();
        }
        else {
            s.push(game(a,num));
        }
    }
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值