首页 > 其他 > 详细

Codeforces I Wanna Be the Guy 题解

时间:2019-10-06 16:58:21      阅读:77      评论:0      收藏:0      [点我收藏+]

这道题非常简单,有两种做法:
1. 用一个数组标记是不是每个关卡小X或小Y都可以通过
1. 用set储存小X和小Y能够通过的关卡(set有去重功能),最后判断set的长度是否等于n

因为楼上已经有第一种做法的题解了,所以,我用第二种方法。

set具体用法可以上百度


代码如下(C++):

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    set<int> s;
    cin>>n;
    int p,q;
    cin>>p;
    for(int i=1;i<=p;i++) {
        int x;
        cin>>x;
        s.insert(x);//将输入的关卡存入set
    }
    cin>>q;
    for(int i=1;i<=q;i++) {
        int x;
        cin>>x;
        s.insert(x);
    }
    if(s.size()==n) cout<<"I become the guy."<<endl;//能够完成游戏
    else cout<<"Oh, my keyboard!"<<endl;//不能
    return 0;
}

 

Codeforces I Wanna Be the Guy 题解

原文:https://www.cnblogs.com/Ryan-juruo/p/11627447.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!