結果

問題 No.408 五輪ピック
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-10-18 18:13:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 1,037 bytes
コンパイル時間 740 ms
コンパイル使用メモリ 69,512 KB
実行使用メモリ 6,056 KB
最終ジャッジ日時 2024-05-02 02:41:34
合計ジャッジ時間 2,405 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 3 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 26 ms
5,376 KB
testcase_06 AC 18 ms
5,376 KB
testcase_07 AC 26 ms
5,376 KB
testcase_08 AC 22 ms
5,376 KB
testcase_09 AC 23 ms
5,376 KB
testcase_10 AC 16 ms
5,376 KB
testcase_11 AC 17 ms
5,376 KB
testcase_12 AC 30 ms
5,376 KB
testcase_13 AC 27 ms
5,376 KB
testcase_14 AC 8 ms
5,376 KB
testcase_15 AC 26 ms
5,376 KB
testcase_16 AC 29 ms
5,376 KB
testcase_17 AC 31 ms
5,376 KB
testcase_18 AC 32 ms
5,376 KB
testcase_19 AC 35 ms
5,444 KB
testcase_20 AC 10 ms
5,376 KB
testcase_21 AC 7 ms
5,376 KB
testcase_22 AC 16 ms
5,376 KB
testcase_23 AC 40 ms
6,056 KB
testcase_24 AC 27 ms
5,744 KB
testcase_25 AC 27 ms
5,616 KB
testcase_26 AC 37 ms
5,576 KB
testcase_27 AC 32 ms
5,592 KB
testcase_28 AC 25 ms
5,376 KB
testcase_29 AC 39 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;

int n, m;
vector<pair<int, int> > hen;
// set<pair<int, int> > memo;
vector<int> e[20010];// e[u2][u1] := 0 -> u1 -> u2
vector<int> G[20010];
int main(void){
	cin >> n >> m;
	rep(i, m){
		int x, y; cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
		G[y].push_back(x);
		hen.push_back(make_pair(x, y));
		// memo.insert(make_pair(x, y));
		// memo.insert(make_pair(y, x));
	}

	/*
		  0
		/   \
	  u1 	 v1   
		\    |
		 u2-v2

	*/

	for(auto u1 : G[0]){
		for(auto u2 : G[u1]){
			if(u1 != u2 && u2 != 0){
				e[u2].push_back(u1);
			}
		}
	}

	for(auto d : hen){
		int u2 = d.first, v2 = d.second;
		if(u2 == 0 || v2 == 0) continue;
		for(auto u1 : e[u2]){
			for(auto v1 : e[v2]){
				if(u1 != v1 && u1 != v2 && v1 != u2 && u2 != v2){
					printf("YES\n");
					return 0;
				}
			}
		}

	}

	printf("NO\n");
	return 0;
}
0