結果

問題 No.408 五輪ピック
ユーザー sugarrrsugarrr
提出日時 2018-08-29 00:09:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,923 bytes
コンパイル時間 1,225 ms
コンパイル使用メモリ 99,264 KB
実行使用メモリ 814,616 KB
最終ジャッジ日時 2023-09-25 15:29:45
合計ジャッジ時間 4,638 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 MLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

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);
    }
    //bool al[n];memset(al,false,sizeof(al));
    //al[0]=true;
    queue<i_i>q;
    q.push(i_i(0,0));
    vector<int>v1,v2;
    while(!q.empty()){
        i_i y=q.front();
        int t=y.first;
        int dep=y.second;
        if(dep==4)break;
        else if(dep==2)v1.pb(t);
        else if(dep==3)v2.pb(t);
        q.pop();
        //al[t]=true;
        
            for(auto x:v[t]){
               // if(!al[x]){
                    q.push(i_i(x,dep+1));
               // }
            }
    }
   /* for(auto x:v1){
        cout<<x<<" ";
    }cout<<endl;
    for(auto x:v2){
        cout<<x<<" ";
    }cout<<endl;
    */
    if(!check(v1,v2)){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
    return 0;
}
0