A - I Wanna Be the Guy
Posted acgoto
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了A - I Wanna Be the Guy相关的知识,希望对你有一定的参考价值。
Problem description
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
4
3 1 2 3
2 2 4
I become the guy.
4
3 1 2 3
2 2 3
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.
解题思路:标记一下1~n出现的数字,如果都出现了,则输出"I become the guy.",否则输出"Oh, my keyboard!",水过!
AC代码:
1 #include<bits/stdc++.h> 2 using namespace std; 3 int main(){ 4 int n,p,q,x;bool flag=false,used[105]; 5 memset(used,false,sizeof(used)); 6 cin>>n>>p; 7 for(int i=1;i<=p;++i){cin>>x;used[x]=true;} 8 cin>>q; 9 for(int i=1;i<=q;++i){cin>>x;used[x]=true;} 10 for(int i=1;i<=n;++i) 11 if(!used[i]){flag=true;break;} 12 if(flag)cout<<"Oh, my keyboard!"<<endl; 13 else cout<<"I become the guy."<<endl; 14 return 0; 15 }
以上是关于A - I Wanna Be the Guy的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces I Wanna Be the Guy 题解
如何从一个Dictionary里取得第i个key和Value
Aiiage Camp Day1 C Littrain wanna be different
Aiiage Camp Day1 H Littrain wanna be rich
Aiiage Camp Day1 E Littrain wanna be small
[Algorithm] A nonrecursive algorithm for enumerating all permutations of the numbers {1,2,...,n}(代码片