結果

問題 No.408 五輪ピック
ユーザー fiordfiord
提出日時 2016-08-07 12:17:18
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 637 bytes
コンパイル時間 536 ms
コンパイル使用メモリ 62,544 KB
実行使用メモリ 46,848 KB
最終ジャッジ日時 2024-04-24 22:05:06
合計ジャッジ時間 6,134 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 541 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 238 ms
5,376 KB
testcase_11 AC 180 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 58 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 197 ms
5,376 KB
testcase_21 AC 66 ms
5,376 KB
testcase_22 AC 539 ms
5,376 KB
testcase_23 AC 44 ms
46,848 KB
testcase_24 AC 687 ms
32,896 KB
testcase_25 WA -
testcase_26 AC 565 ms
5,376 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
using namespace std;
const int N=20000;
int n;
vector<int> edge[N];
bool flag[N][N];
void dfs(int p,int cur,int d){
	if(d==3){
		flag[p][cur]=true;
		return;
	}
	for(int i=0;i<edge[cur].size();i++){
		if(edge[cur][i]==p)	continue;
		dfs(cur,edge[cur][i],d+1);
	}
	return;
}
int main(){
	int m;	cin>>n>>m;
	for(int i=0;i<n;i++){
		int a,b;	cin>>a>>b;	a--;	b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	dfs(0,0,0);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(flag[i][j]&&flag[j][i]){
				cout<<"YES"<<endl;
				return 0;
			}
		}
	}
	cout<<"NO"<<endl;
	return 0;
}
	
0