結果

問題 No.408 五輪ピック
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-10-18 17:42:59
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,650 bytes
コンパイル時間 874 ms
コンパイル使用メモリ 73,984 KB
実行使用メモリ 14,880 KB
最終ジャッジ日時 2024-05-02 02:36:38
合計ジャッジ時間 8,960 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 72 ms
9,228 KB
testcase_06 AC 36 ms
6,944 KB
testcase_07 AC 58 ms
7,896 KB
testcase_08 AC 50 ms
7,764 KB
testcase_09 AC 51 ms
7,680 KB
testcase_10 AC 36 ms
6,948 KB
testcase_11 AC 34 ms
6,944 KB
testcase_12 AC 68 ms
8,648 KB
testcase_13 AC 67 ms
9,132 KB
testcase_14 AC 13 ms
6,940 KB
testcase_15 AC 72 ms
9,316 KB
testcase_16 AC 75 ms
9,356 KB
testcase_17 AC 77 ms
9,500 KB
testcase_18 AC 78 ms
9,460 KB
testcase_19 AC 82 ms
9,540 KB
testcase_20 AC 18 ms
6,944 KB
testcase_21 AC 11 ms
6,944 KB
testcase_22 AC 29 ms
6,940 KB
testcase_23 AC 81 ms
9,684 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
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 || v1 == u2 || u1 == v2) continue;
					if(memo.count(make_pair(u2, v2))){
						printf("YES\n");
						return 0;
					}
				}
			}
		}
	}
	printf("NO\n");
	return 0;
}
0