CF - 469A. I Wanna Be the Guy - 模拟

1.题目描述:

A. I Wanna Be the Guy
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

There is a game called "I Wanna Be the Guy", consisting of n levels. Little X and his friend Little Y are addicted to the game. Each of them wants to pass the whole game.

Little X can pass only p levels of the game. And Little Y can pass only q levels of the game. You are given the indices of levels Little X can pass and the indices of levels Little Y can pass. Will Little X and Little Y pass the whole game, if they cooperate each other?

Input

The first line contains a single integer n (1 ≤  n ≤ 100).

The next line contains an integer p (0 ≤ p ≤ n) at first, then follows p distinct integers a1, a2, ..., ap (1 ≤ ai ≤ n). These integers denote the indices of levels Little X can pass. The next line contains the levels Little Y can pass in the same format. It's assumed that levels are numbered from 1 to n.

Output

If they can pass all the levels, print "I become the guy.". If it's impossible, print "Oh, my keyboard!" (without the quotes).

Examples
input
4
3 1 2 3
2 2 4
output
I become the guy.
input
4
3 1 2 3
2 2 3
output
Oh, my keyboard!
Note

In the first sample, Little X can pass levels [1 2 3], and Little Y can pass level [2 4], so they can pass all the levels both.

In the second sample, no one can pass level 4.

2.题意概述:

两人打游戏,一个人可以过第若干关卡,另一个人又可以过若干关卡,问两人配合能否全部通关

3.解题思路:

直接模拟扫一遍就好了

4.AC代码:

#include 
#include 
#define N 101
using namespace std;
int vis[N];


int main()
{
	int n, a, b, flag;
	while (scanf("%d", &n) != EOF)
	{
		memset(vis, 0, sizeof(vis));
		scanf("%d", &a);
		for (int i = 0; i < a; i++)
		{
			int tmp;
			scanf("%d", &tmp);
			vis[tmp]++;
		}
		scanf("%d", &b);
		for (int i = 0; i < b; i++)
		{
			int tmp;
			scanf("%d", &tmp);
			vis[tmp]++;
		}
		flag = 1;
		for (int i = 1; i <= n; i++)
			if (!vis[i])
			{
				flag = 0;
				break;
			}
		if (flag)
			puts("I become the guy.");
		else
			puts("Oh, my keyboard!");
	}
    return 0;
}

你可能感兴趣的:(模拟)