結果

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

テストケース

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

ソースコード

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 10

int n,m;
vector<int>v[N];
bool ans=false;
bool al[N];

void dfs(int t,int d){
    if(d==5||ans)return;
    else if(d==4){
        for(auto x:v[t])if(x==0){
            ans=true;
        }
    }else{
        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;
    al[0]=true;
    dfs(0,0);
    if(ans)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    return 0;
}
0