結果

問題 No.408 五輪ピック
ユーザー sugarrrsugarrr
提出日時 2018-08-29 00:44:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,513 bytes
コンパイル時間 955 ms
コンパイル使用メモリ 85,524 KB
実行使用メモリ 5,164 KB
最終ジャッジ日時 2023-09-25 16:32:55
合計ジャッジ時間 4,183 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 26 ms
4,560 KB
testcase_06 AC 16 ms
4,580 KB
testcase_07 AC 23 ms
4,784 KB
testcase_08 AC 19 ms
4,400 KB
testcase_09 AC 19 ms
4,420 KB
testcase_10 WA -
testcase_11 AC 15 ms
4,404 KB
testcase_12 AC 28 ms
4,656 KB
testcase_13 AC 24 ms
4,712 KB
testcase_14 WA -
testcase_15 AC 50 ms
4,664 KB
testcase_16 AC 25 ms
4,564 KB
testcase_17 AC 27 ms
4,900 KB
testcase_18 AC 28 ms
4,716 KB
testcase_19 AC 31 ms
4,868 KB
testcase_20 AC 9 ms
4,380 KB
testcase_21 AC 6 ms
4,380 KB
testcase_22 AC 14 ms
4,504 KB
testcase_23 AC 35 ms
4,724 KB
testcase_24 WA -
testcase_25 AC 47 ms
4,588 KB
testcase_26 AC 32 ms
5,164 KB
testcase_27 AC 55 ms
4,684 KB
testcase_28 AC 644 ms
4,380 KB
testcase_29 AC 645 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
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;}

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


#define N 20005

int n,m;
vector<int>v[N];
bool al[N];
bool possi[N][2];

void dfs(int t,int d){
    if(d==4)return;
    else if(d==3){
        possi[t][1]=true;
        return;
    }else if(d==2){
        possi[t][0]=true;
    }
        for(auto x:v[t]){
            if(!al[x]){
                al[x]=true;
                dfs(x,d+1);
                al[x]=false;
            }
        }
    
}


int main(){
    cin>>n>>m;
    rep(i,0,m-1){
        int s,t;cin>>s>>t;s--;t--;
        v[s].pb(t);
        v[t].pb(s);
    }
    
    rep(i,1,n-1)al[i]=false;
    memset(possi,false,sizeof(possi));
    
    al[0]=true;
    dfs(0,0);
    /*rep(i,0,n-1){
        cout<<possi[i][0]<<" "<<possi[i][1]<<endl;
    }*/
    rep(i,1,n-1){
        if(possi[i][0]&&possi[i][1]){cout<<"YES"<<endl;return 0;}
    }
    cout<<"NO"<<endl;
    return 0;
}
0