結果

問題 No.408 五輪ピック
ユーザー kapokapo
提出日時 2016-08-06 21:00:12
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,489 bytes
コンパイル時間 1,037 ms
コンパイル使用メモリ 94,552 KB
実行使用メモリ 9,856 KB
最終ジャッジ日時 2024-04-24 19:28:21
合計ジャッジ時間 4,467 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 23 ms
6,144 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 21 ms
5,504 KB
testcase_09 AC 22 ms
5,376 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 24 ms
5,888 KB
testcase_14 AC 8 ms
5,376 KB
testcase_15 AC 29 ms
7,424 KB
testcase_16 AC 25 ms
5,632 KB
testcase_17 AC 29 ms
5,632 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 10 ms
5,376 KB
testcase_21 AC 6 ms
5,376 KB
testcase_22 AC 13 ms
5,504 KB
testcase_23 AC 44 ms
9,856 KB
testcase_24 WA -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 20 ms
6,144 KB
testcase_29 AC 22 ms
6,272 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

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>
#include <unordered_set>
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];
unordered_set<int> 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);
	}

	for (int b: E1[0]) {
		for (int c: E1[b]) {
			if (c==0) continue;
			E2[c].insert(b);
			//printf("b=%d c=%d\n",b,c);
		}
	}

	rep(i,0,M-1) {
		if (!E2[i].size()) continue;
		rep(j,i+1,M) {
			if (!E2[j].size()) continue;
			//printf("i=%d j=%d\n",i,j);
			auto it = find(all(E1[i]), j);
			if (it != E1[i].end()) {
				if (E2[i].size() == 1 && E2[j].size() == 1 && E2[i] != E2[j]
				||  E2[i].size()>=1 && E2[j].size()>=1 && max(E2[i].size(), E2[j].size())>=2) {
					cout << "YES" << endl;
					return 0;
				}
			} 
		}
	}

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