結果

問題 No.408 五輪ピック
ユーザー sugarrr
提出日時 2018-08-29 00:44:52
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,513 bytes
コンパイル時間 777 ms
コンパイル使用メモリ 91,900 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-18 13:01:20
合計ジャッジ時間 3,767 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28 WA * 4
権限があれば一括ダウンロードができます

ソースコード

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