結果

問題 No.408 五輪ピック
ユーザー srup٩(๑`н´๑)۶
提出日時 2016-10-18 17:41:10
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,626 bytes
コンパイル時間 645 ms
コンパイル使用メモリ 74,084 KB
実行使用メモリ 14,644 KB
最終ジャッジ日時 2024-11-22 12:24:14
合計ジャッジ時間 17,131 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28 WA * 3 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

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