Hust oj 2121 你猜猜(水题)

你猜猜
Time Limit: 1000 MSMemory Limit: 32768 K
Total Submit: 270(70 users)Total Accepted: 91(62 users)Rating: Special Judge: No
Description


ACM集训队不培训的闲暇时间里,Woods就会和他的GrilFriendGF)玩一些小游戏(咳咳…不要邪恶)。GF为了考验Woods和她的默契程度,玩了个“你猜猜”的游戏,规则如下:

GF在心里想一个数,然后Woods开始猜,对于Woods每次猜的数,GF可以有三种回答:too hightoo lowright on。分别表示太高了,太低了,猜对了。Woods非常了解GF,每次都很快猜对。但是GF非常好强,有的时候就是不想让Woods猜对,于是她可能会故意错误的回答。请你判断一下,GF到底有没有故意回答错误?(参见第一组样例。Woods10GF说太高了。Woods3GF说太低了。Woods4GF说太高了。Woods2GF说对了。但显然2不是正确答案。因为Woods3的时候就已经太低了。)


Input

多组测试数据。每组数据包含许多组猜测。每组猜测包括两行,第一行为一个数字代表Woods猜的数,第二行为GF的一个回答,只包含too hightoo lowright on三种。每组数据以right on结束。

 
Output
    每组数据输出一行。如果GF没有故意回答错误,输出"GF may be honest."如果GF有故意错误回答,输出"GF is dishonest."(引号不输出)。
Sample Input
10
too high
3
too low
4
too high
2
right on
5
too low
7
too high
6
right on
 
Sample Output

GF is dishonest.GF may be honest.

读第一遍的时候没反应过来,还以为是什么难题,后来才明白,用两个数组分别存low和high,再用right和他们分别比较,如果比low小或者比high大都是错的,要注意等于也算错的,因为这个WA了一发

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn = 105;
int high[maxn];
int low[maxn];
char a[maxn];

int main()
{
    int n;
    int cnt1 = 0,cnt2 = 0;
    int flag = 0;
    while(~scanf("%d",&n))
    {
        getchar();
        gets(a);
        if(strcmp(a,"too high") == 0)
        {
            high[cnt1++] = n;
        }
        if(strcmp(a,"too low") == 0)
        {
            low[cnt2++] = n;
        }
        if(strcmp(a,"right on") == 0)
        {
            for(int i=0;i<cnt1;i++)
            {
                if(n >= high[i])
                {
                    flag = 1;
                    break;
                }
            }
            for(int i=0;i<cnt2;i++)
            {
                if(n <= low[i] || flag == 1)
                {
                    flag = 1;
                    break;
                }
            }
            if(flag == 1)
                printf("GF is dishonest.\n");
            else
                printf("GF may be honest.\n");
            cnt1 = 0;
            cnt2 = 0;
            flag = 0;
        }
    }
    return 0;
}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值