結果

問題 No.408 五輪ピック
ユーザー rapurasurapurasu
提出日時 2016-08-05 23:28:52
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,547 bytes
コンパイル時間 1,530 ms
コンパイル使用メモリ 160,616 KB
実行使用メモリ 5,632 KB
最終ジャッジ日時 2024-04-24 18:28:05
合計ジャッジ時間 3,713 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 24 ms
5,376 KB
testcase_06 AC 17 ms
5,376 KB
testcase_07 AC 25 ms
5,376 KB
testcase_08 AC 21 ms
5,376 KB
testcase_09 AC 22 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 17 ms
5,376 KB
testcase_12 AC 29 ms
5,376 KB
testcase_13 AC 25 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 25 ms
5,376 KB
testcase_16 AC 28 ms
5,376 KB
testcase_17 AC 30 ms
5,376 KB
testcase_18 AC 31 ms
5,376 KB
testcase_19 AC 34 ms
5,376 KB
testcase_20 AC 10 ms
5,376 KB
testcase_21 AC 6 ms
5,376 KB
testcase_22 AC 16 ms
5,376 KB
testcase_23 AC 36 ms
5,632 KB
testcase_24 AC 23 ms
5,376 KB
testcase_25 AC 24 ms
5,376 KB
testcase_26 AC 35 ms
5,504 KB
testcase_27 AC 25 ms
5,376 KB
testcase_28 AC 19 ms
5,376 KB
testcase_29 AC 20 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
bool dp[6][20001];
int p1[6][20001];
vector<int>v[20001];
int main(){
        int N,M;
        cin>>N>>M;
        REP(i,M){
          int a,b;
          cin>>a>>b;
          v[a].push_back(b);
          v[b].push_back(a);
        }
	REP(i,6){
	   REP(j,20001){
             dp[i][j]=false;
	   }
	}
        REP(i,6){
	  REP(j,20001){
             p1[i][j]=-1;
	   }
	}
        dp[0][1]=true;
        REP(i,5){
            REP(j,N+1){
               if(dp[i][j]){
                  REP(k,v[j].size()){
                      int x=v[j][k];
                      if(x!=1){
                         if(p1[i+1][x]!=-1||p1[i][j]!=x){
                            p1[i+1][x]=j;
                            dp[i+1][x]=true;
                         }
                      }
                  }
               }
            }
        }
        bool check=false;
        REP(i,N+1){
            if(i==1)continue;
            if(dp[4][i]==true){
               REP(j,v[i].size()){
                   if(v[i][j]==1)check=true;
               }
            }
            if(check)break;
        }
/*
        REP(i,6){
           REP(j,N+1){
           cout<<dp[i][j];
           }
           cout<<endl;
        }
*/
        if(check){
           cout<<"YES"<<endl;
        }else{
           cout<<"NO"<<endl;
        }
	
	return(0);
}
0