結果

問題 No.408 五輪ピック
ユーザー kapokapo
提出日時 2016-08-06 15:26:19
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,521 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 86,344 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-24 19:07:44
合計ジャッジ時間 8,325 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,248 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 25 ms
5,376 KB
testcase_06 AC 18 ms
5,376 KB
testcase_07 AC 26 ms
5,376 KB
testcase_08 AC 21 ms
5,376 KB
testcase_09 AC 22 ms
5,376 KB
testcase_10 AC 18 ms
5,376 KB
testcase_11 AC 16 ms
5,376 KB
testcase_12 AC 29 ms
5,376 KB
testcase_13 AC 25 ms
5,376 KB
testcase_14 AC 7 ms
5,376 KB
testcase_15 AC 26 ms
5,504 KB
testcase_16 AC 27 ms
5,376 KB
testcase_17 AC 30 ms
5,376 KB
testcase_18 AC 32 ms
5,376 KB
testcase_19 AC 34 ms
5,376 KB
testcase_20 AC 10 ms
5,376 KB
testcase_21 AC 7 ms
5,376 KB
testcase_22 AC 15 ms
5,376 KB
testcase_23 AC 35 ms
5,760 KB
testcase_24 AC 24 ms
5,376 KB
testcase_25 AC 74 ms
5,504 KB
testcase_26 AC 36 ms
5,376 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> V;
typedef vector<vector<int> > VV;
typedef long long ll;
const int inf = 2e9;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int N, M;
V E1[20001];
vector<Pii> E2[20001];

int main()
{
	cin >> N >> M;
	rep(i,0,M) {
		int a, b; cin >> a >> b;
		a--; b--;
		E1[a].pb(b);
		E1[b].pb(a);
	}
	// 0からb,cに辺を伸ばす
	for (int b: E1[0]) {
		for (int c: E1[b]) {
			if (c==0) continue;
			E2[0].pb(mp(b,c));
		}
	}
	// cからd,eに辺を伸ばす
	rep(i,0,len(E2[0])) {
		int b = E2[0][i].first;
		int c = E2[0][i].second;
		for (int d: E1[c]) {
			if (d==0 || d==b) continue;
			for (int e: E1[d]) {
				if (e==0 || e==b || e==c) continue;
				// eから0に辺を伸ばせるか判定
				rep(j,0,len(E1[e])) {
					//printf("b=%d c=%d d=%d e=%d E1[e][j]=%d\n",b,c,d,e,E1[e][j]);
					if (0 == E1[e][j]) {
						cout << "YES" << endl;
						return 0;
					}
				}
			}
		}
	}

	cout << "NO" << endl;
	return 0;
}
0