結果

問題 No.408 五輪ピック
ユーザー sugarrrsugarrr
提出日時 2018-08-29 00:13:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,556 bytes
コンパイル時間 1,414 ms
コンパイル使用メモリ 95,456 KB
実行使用メモリ 6,664 KB
最終ジャッジ日時 2023-09-25 15:32:04
合計ジャッジ時間 3,424 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 30 ms
4,568 KB
testcase_06 AC 16 ms
4,464 KB
testcase_07 AC 23 ms
4,640 KB
testcase_08 AC 20 ms
4,376 KB
testcase_09 AC 20 ms
4,380 KB
testcase_10 WA -
testcase_11 AC 15 ms
4,376 KB
testcase_12 AC 27 ms
4,504 KB
testcase_13 AC 30 ms
4,556 KB
testcase_14 WA -
testcase_15 AC 31 ms
4,684 KB
testcase_16 AC 32 ms
4,460 KB
testcase_17 AC 28 ms
4,420 KB
testcase_18 AC 29 ms
4,588 KB
testcase_19 AC 31 ms
4,592 KB
testcase_20 AC 9 ms
4,380 KB
testcase_21 AC 5 ms
4,376 KB
testcase_22 AC 14 ms
4,476 KB
testcase_23 AC 51 ms
6,664 KB
testcase_24 WA -
testcase_25 AC 28 ms
4,496 KB
testcase_26 AC 33 ms
4,784 KB
testcase_27 AC 27 ms
4,576 KB
testcase_28 AC 22 ms
4,612 KB
testcase_29 AC 22 ms
4,640 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}

////////////////////////////////////////

bool check(vector<int>v,vector<int>u){
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    sort(u.begin(),u.end());
    u.erase(unique(u.begin(),u.end()),u.end());
    
    set<int>s;
    ll vv=v.size(),uu=u.size();
    for(auto x:v)s.insert(x);
    for(auto x:u)s.insert(x);
    ll ss=s.size();
    return ss==vv+uu;
}

int main(){
    int n,m;cin>>n>>m;
    vector<int>v[n];
    rep(i,0,m-1){
        int s,t;cin>>s>>t;s--;t--;
        v[s].pb(t);
        v[t].pb(s);
    }
    vector<int>v0,v1,v2;
    for(auto x:v[0])v0.pb(x);
    for(auto x:v0){
        for(auto y:v[x])v1.pb(y);
    }
    sort(v1.begin(),v1.end());
    v1.erase(unique(v1.begin(),v1.end()),v1.end());
    for(auto x:v1){
        for(auto y:v[x])v2.pb(y);
    }
    
    if(!check(v1,v2)){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
    return 0;
}
0