11.11这天,lgw1860依然是1111,大三的他今天打算摆脱光棍生活(简称“脱光”)。于是他鼓足勇气,对已经暗恋已久的MM告白。但MM为了考查lgw1860的聪明指数(MM都喜欢聪明的帅哥),想出了一个猜数字游戏。MM想到一个1到1000之间的数字,让lgw1860猜。对于每一次猜测,如果lgw1860猜出的数字大于MM心目中的数字,则MM会给出“big”提示,如果猜出的数字小于MM心目中的数字,则MM会给出“small”提示,相等则“equal”。而MM正是要考查lgw1860的反应能力,她可能会撒慌给出错误的提示。lgw1860则会根据每次猜测的结果最终给出自己的一个判断,如果判断为“true”则说明lgw1860认为MM没有撒慌,为“false”则认为MM撒慌。如果lgw1860猜测正确的话他将会摆脱1111,否则1111依旧。现在请你来判断lgw1860的命运。
Description
输入数据有多组。 每组包含: 第一行一个数字N,表示猜数游戏进行的次数,(1<= N <= 1000)。 接下来N行,每行包含一个1到1000之间的整数和一个字符串,整数表示lgw1860猜测的数字,字符串表示MM给出的提示,提示最终均以“equal”结束。 最后一行是一个字符串,“true”或者“false”,表示lgw1860最终给出的判断。
Input
如果lgw1860可以摆脱1111,则输出“22”(不包含引号),否则输出“11”。
Output
1
2
3
4
5
6
7
8
9
10
11
|
3
8 small
50 big
20 equal
true
3
8 small
50 small
20 equal
true
|
Sample Input
1
2
3
|
2
11
|
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;
void fun(int *a, int Start, int End)
{
for (int i = Start; i <= End; i++)
{
a[i] = 1;
}
}
int main()
{
int n;
while (cin >> n)
{
string str;
int a;
int flag = 1;
int num[1001] = { 0 };//0表示数字可能是那个数
for (int i = 0; i < n; i++)
{
cin >> a >> str;
if (str == "small")
{
fun(num, 0, a);
}
else if (str == "big")
{
fun(num, a, 1000);
}
else
{
if (num[a] != 0)
flag = 0;
}
}
cin >> str;
if (str == "true")
{
if (flag == 0)
{
cout << "11" << endl;
}
else
{
cout << "22" << endl;
}
}
else
{
if (flag == 1)
{
cout << "11" << endl;
}
else
{
cout << "22" << endl;
}
}
}
return 0;
}