結果

問題 No.408 五輪ピック
ユーザー sugim48sugim48
提出日時 2016-08-05 22:36:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 581 ms / 5,000 ms
コード長 1,347 bytes
コンパイル時間 1,067 ms
コンパイル使用メモリ 109,200 KB
実行使用メモリ 4,796 KB
最終ジャッジ日時 2023-08-06 21:19:32
合計ジャッジ時間 5,097 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 11 ms
4,380 KB
testcase_06 AC 273 ms
4,380 KB
testcase_07 AC 15 ms
4,380 KB
testcase_08 AC 10 ms
4,376 KB
testcase_09 AC 10 ms
4,380 KB
testcase_10 AC 183 ms
4,376 KB
testcase_11 AC 158 ms
4,380 KB
testcase_12 AC 19 ms
4,384 KB
testcase_13 AC 11 ms
4,376 KB
testcase_14 AC 85 ms
4,376 KB
testcase_15 AC 11 ms
4,380 KB
testcase_16 AC 13 ms
4,376 KB
testcase_17 AC 14 ms
4,376 KB
testcase_18 AC 15 ms
4,380 KB
testcase_19 AC 16 ms
4,700 KB
testcase_20 AC 164 ms
4,380 KB
testcase_21 AC 94 ms
4,376 KB
testcase_22 AC 272 ms
4,380 KB
testcase_23 AC 17 ms
4,628 KB
testcase_24 AC 581 ms
4,520 KB
testcase_25 AC 13 ms
4,384 KB
testcase_26 AC 290 ms
4,796 KB
testcase_27 AC 183 ms
4,376 KB
testcase_28 AC 25 ms
4,380 KB
testcase_29 AC 16 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	random_device rd;
	mt19937 mt(rd());
	int N, M; cin >> N >> M;
	vector<vector<int> > G(N);
	while (M--) {
		int u, v; scanf("%d%d", &u, &v);
		u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for (int t = 0; t < 1000; t++) {
		vector<int> color(N);
		color[0] = -1;
		for (int u = 1; u < N; u++)
			color[u] = mt() % 4;
		vector<bool> a(N);
		a[0] = true;
		for (int c = 0; c < 4; c++) {
			vector<bool> _a(N);
			for (int u = 0; u < N; u++)
				if (a[u])
					for (int v: G[u])
						if (color[v] == c)
							_a[v] = true;
			a = _a;
		}
		for (int v: G[0])
			if (a[v]) {
				cout << "YES" << endl;
				return 0;
			}
	}
	cout << "NO" << endl;
}
0