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;
    }
  • 相关阅读:
    HDU 4472 Count DP题
    HDU 1878 欧拉回路 图论
    CSUST 1503 ZZ买衣服
    HDU 2085 核反应堆
    HDU 1029 Ignatius and the Princess IV
    UVa 11462 Age Sort
    UVa 11384
    UVa 11210
    LA 3401
    解决学一会儿累了的问题
  • 原文地址:https://www.cnblogs.com/Ryan-juruo/p/11627447.html
Copyright © 2011-2022 走看看