結果

問題 No.408 五輪ピック
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-10-18 17:41:10
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,626 bytes
コンパイル時間 734 ms
コンパイル使用メモリ 73,800 KB
実行使用メモリ 16,364 KB
最終ジャッジ日時 2024-05-02 02:36:15
合計ジャッジ時間 9,444 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 84 ms
9,224 KB
testcase_06 AC 38 ms
6,784 KB
testcase_07 AC 63 ms
8,080 KB
testcase_08 AC 54 ms
7,680 KB
testcase_09 AC 55 ms
7,680 KB
testcase_10 AC 39 ms
6,784 KB
testcase_11 AC 36 ms
6,608 KB
testcase_12 AC 80 ms
8,652 KB
testcase_13 AC 78 ms
9,264 KB
testcase_14 AC 13 ms
5,376 KB
testcase_15 AC 81 ms
9,196 KB
testcase_16 AC 85 ms
9,220 KB
testcase_17 AC 87 ms
9,464 KB
testcase_18 AC 96 ms
9,456 KB
testcase_19 AC 95 ms
9,540 KB
testcase_20 AC 18 ms
5,504 KB
testcase_21 AC 11 ms
5,376 KB
testcase_22 AC 32 ms
6,400 KB
testcase_23 AC 97 ms
9,680 KB
testcase_24 WA -
testcase_25 AC 80 ms
9,364 KB
testcase_26 AC 103 ms
9,720 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

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> 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 d : hen){
		int u1 = d.first, v1 = d.second;
		// printf("u1 %d v1 %d\n", u1, v1);
		for(auto u2 : G[u1]){
			for(auto v2 : G[v1]){
				// printf("u2 %d v2 %d\n", u2, v2);
				if(u2 == v1) continue;
				if(u1 == v2) continue;
				if(u2 == v1) continue;
				// printf("u2 %d v2 %d\n", u2, v2);

				for (int p = 0; p < n; ++p){
					if(p == u1 || p == u2 || p == v1 || p == v2) continue;
					if(memo.count(make_pair(u2, p)) && memo.count(make_pair(v2, p))){
						if(u1 == 0 || u2 == 0 || v1 == 0 || v2 == 0 || p == 0){
							// printf("ok u1 %d v1 %d\n", u1, v1);
							// printf("ok u2 %d v2 %d\n", u2, v2);
							// printf("p %d\n", p);
							printf("YES\n");
							return 0;
						}
					}
				}
			}
		}
	}
	*/
	for(auto u1 : G[0]){
		for(auto v1 : G[0]){
			if(u1 == v1) continue;
			for(auto u2 : G[u1]){
				for(auto v2 : G[v1]){
					if(u2 == v2 || u2 == 0 || v2 == 0) continue;
					if(memo.count(make_pair(u2, v2))){
						printf("YES\n");
						return 0;
					}
				}
			}
		}
	}
	printf("NO\n");
	return 0;
}
0