码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces I Wanna Be the Guy 题解

时间:2019-10-06 16:50:30      阅读:82      评论:0      收藏:0      [点我收藏+]

标签:功能   set   i++   def   std   clu   include   完成   数组   

这道题非常简单,有两种做法:
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 题解

标签:功能   set   i++   def   std   clu   include   完成   数组   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!