估计再过几天就不会做ACM了,最近也没有什么状态,在无聊的时候还是来水完 我最后几道吧。
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
#include<iomanip>
#include<set>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<string>
using namespace std;
int main()
{
freopen("in.txt","r",stdin);
int t;
char a[11],b[11];
int n;
int i,j,k;
while (cin>>n,n)
{
bool v[12];
memset(v,true,sizeof(v));
bool ans=true;
v[0]=false;
v[11]=false;
while (true)
{
cin>>a>>b;
if (a[0]=='r')
{
if (!v[n])
ans=false;
break;
}
if (b[0]=='h')
{
for (i=n-1;i;i--)
if (v[i])
break;
if (i==0)
ans=false;
for (i=n;i<=10;i++)
v[i]=false;
}
else
{
for (i=n+1;i<=10;i++)
if (v[i])
break;
if (i==11)
ans=false;
for (i=n;i;i--)
v[i]=false;
}
cin>>n;
}
if (ans)
puts("Stan may be honest");
else
puts("Stan is dishonest");
}
}
Guessing Game
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 13018 | Accepted: 4564 |
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.
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
10 too high 3 too low 4 too high 2 right on 5 too low 7 too high 6 right on 0
Sample Output
Stan is dishonest Stan may be honest
Source