zoukankan      html  css  js  c++  java
  • Codeforces I Wanna Be the Guy 题解

    这道题非常简单,有两种做法:
      1. 用一个数组标记是不是每个关卡小X或小Y都可以通过
      2. 用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;
    }
  • 相关阅读:
    Redis 安装和启动
    有序的map类--LinkedHashMap
    Springmvc
    工厂模式
    Top K
    判断链表是否有环
    注解
    Spring 事务
    热点账户高并发解决方案
    sql优化
  • 原文地址:https://www.cnblogs.com/Ryan-juruo/p/11627447.html
Copyright © 2011-2022 走看看