跳过正文
  1. Posts/

uva 489

·2 分钟
目录

In ``Hangman Judge,’’ you are to write a program that judges a series of Hangman games. For each game, the answer to the puzzle is given as well as the guesses. Rules are the same as the classic game of hangman, and are given as follows:

  1. The contestant tries to solve to puzzle by guessing one letter at a time.
  2. Every time a guess is correct, all the characters in the word that match the guess will be ``turned over.'' For example, if your guess is ``o'' and the word is ``book'', then both ``o''s in the solution will be counted as ``solved.''
  3. Every time a wrong guess is made, a stroke will be added to the drawing of a hangman, which needs 7 strokes to complete. Each unique wrong guess only counts against the contestant once.

   ______
   |  |
   |  O
   | /|
   |  |
   | /
 __|_
 |   |______
 |_________|

  4. If the drawing of the hangman is completed before the contestant has successfully guessed all the characters of the word, the contestant loses.
  5. If the contestant has guessed all the characters of the word before the drawing is complete, the contestant wins the game.
  6. If the contestant does not guess enough letters to either win or lose, the contestant chickens out.

Your task as the ``Hangman Judge’’ is to determine, for each game, whether the contestant wins, loses, or fails to finish a game.

Input
#

Your program will be given a series of inputs regarding the status of a game. All input will be in lower case. The first line of each section will contain a number to indicate which round of the game is being played; the next line will be the solution to the puzzle; the last line is a sequence of the guesses made by the contestant. A round number of -1 would indicate the end of all games (and input).

Output
#

The output of your program is to indicate which round of the game the contestant is currently playing as well as the result of the game. There are three possible results:

You win.
You lose.
You chickened out.

Sample Input
#

1
cheese
chese
2
cheese
abcdefg
3
cheese
abcdefgij
-1

Sample Output
#

Round 1
You win.
Round 2
You chickened out.
Round 3
You lose.

水题还wa.真是药丸.药丸啊…

 1/*************************************************************************
 2	> File Name: code/uva/489.cpp
 3	> Author: 111qqz
 4	> Email: rkz2013@126.com
 5	> Created Time: 2015年09月23日 星期三 19时34分34秒
 6 ************************************************************************/
 7
 8#include<iostream>
 9#include<iomanip>
10#include<cstdio>
11#include<algorithm>
12#include<cmath>
13#include<cstring>
14#include<string>
15#include<map>
16#include<set>
17#include<queue>
18#include<vector>
19#include<stack>
20#include<cctype>
21#define y1 hust111qqz
22#define yn hez111qqz
23#define j1 cute111qqz
24#define ms(a,x) memset(a,x,sizeof(a))
25#define lr dying111qqz
26using namespace std;
27#define For(i, n) for (int i=0;i<int(n);++i)
28typedef long long LL;
29typedef double DB;
30const int inf = 0x3f3f3f3f;
31const int N=30;
32int a[N];
33int main()
34{
35  #ifndef  ONLINE_JUDGE
36   freopen("in.txt","r",stdin);
37  #endif
38    int cas;
39    while (scanf("%d",&cas)!=EOF)
40    {
41	if (cas==-1) break;
42	ms(a,0);
43	printf("Round %d\n",cas);
44
45	string st1,st2;
46	cin>>st1>>st2;
47	int len1 = st1.length();
48	for ( int i = 0 ; i < len1 ; i++)
49	{
50	    int tmp = st1[i]-'a';
51	    a[tmp]++;
52	}
53	int len2 = st2.length();
54	int cnt = 0 ;
55	int sum = 0 ;
56	int state = 0;
57	for ( int i = 0 ; i < len2 ; i++)
58	{
59	    int tmp = st2[i]-'a';
60	    if (a[tmp]==0)
61	    {
62		cnt++;
63	    }
64	    else
65	    {
66		sum += a[tmp];
67		a[tmp] =  0;
68	    }
69	    if (cnt>=7) break;
70	    if (sum==len1)
71	    {
72		state = 1;
73		break;
74	    }
75	}
76	if (state ==1)
77	{
78	    puts("You win.");
79	    continue;
80	}
81//	cout<<"cnt:"<<cnt<<endl;
82	if (cnt<7)
83	{
84	    puts("You chickened out.");
85	}
86	else
87	{
88	    puts("You lose.");
89	}
90    }
91
92 #ifndef ONLINE_JUDGE
93  fclose(stdin);
94  #endif
95	return 0;
96}

相关文章

poj 2159 Ancient Cipher(水)

·1 分钟
由于顺序是可以改变的. 所以考虑是否可以映射.只要存在字母对应出现的次数都相同.那么就可以通过映射得到. 具体是开一个数组记录每个字母出现的次数… 然后sort

codeforces #317 div2 A. Arrays (水)

·1 分钟
应该3分钟过的题。。。 结果花了8分钟。。。ssssad 1/************************************************************************* 2 > File Name: code/cf/#317/A.cpp 3 > Author: 111qqz 4 > Email: rkz2013@126.com 5 > Created Time: 2015年08月23日 星期日 00时29分47秒 6 ************************************************************************/ 7 8#include<iostream> 9#include<iomanip> 10#include<cstdio> 11#include<algorithm> 12#include<cmath> 13#include<cstring> 14#include<string> 15#include<map> 16#include<set> 17#include<queue> 18#include<vector> 19#include<stack> 20#include<cctype> 21#define y1 hust111qqz 22#define yn hez111qqz 23#define j1 cute111qqz 24#define ms(a,x) memset(a,x,sizeof(a)) 25#define lr dying111qqz 26using namespace std; 27#define For(i, n) for (int i=0;i<int(n);++i) 28typedef long long LL; 29typedef double DB; 30const int inf = 0x3f3f3f3f; 31const int N=1E5+7; 32int na,nb,k,m; 33int a[N],b[N]; 34int main() 35{ 36 #ifndef ONLINE_JUDGE 37 freopen("in.txt","r",stdin); 38 #endif 39 cin>>na>>nb; 40 cin>>k>>m; 41 for ( int i = 1 ; i <= na ; i++){ 42 scanf("%d",&a[i]); 43 } 44 for ( int i = 1 ; i<= nb ; i++){ 45 scanf("%d",&b[i]); 46 } 47 if (a[k]<b[nb-m+1]){ 48 puts("YES"); 49 } 50 else 51 { 52 puts("NO"); 53 } 54 55 56 #ifndef ONLINE_JUDGE 57 fclose(stdin); 58 #endif 59 return 0; 60}