結果

問題 No.408 五輪ピック
ユーザー pekempeypekempey
提出日時 2016-08-05 22:43:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 298 ms / 5,000 ms
コード長 823 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 148,208 KB
実行使用メモリ 54,344 KB
最終ジャッジ日時 2023-08-06 21:24:45
合計ジャッジ時間 4,883 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 13 ms
8,492 KB
testcase_06 AC 149 ms
52,144 KB
testcase_07 AC 22 ms
40,132 KB
testcase_08 AC 11 ms
9,372 KB
testcase_09 AC 14 ms
17,036 KB
testcase_10 AC 138 ms
35,796 KB
testcase_11 AC 127 ms
31,284 KB
testcase_12 AC 183 ms
39,436 KB
testcase_13 AC 13 ms
8,536 KB
testcase_14 AC 49 ms
18,540 KB
testcase_15 AC 12 ms
5,668 KB
testcase_16 AC 15 ms
10,548 KB
testcase_17 AC 16 ms
15,328 KB
testcase_18 AC 20 ms
23,468 KB
testcase_19 AC 24 ms
36,020 KB
testcase_20 AC 91 ms
32,860 KB
testcase_21 AC 51 ms
20,472 KB
testcase_22 AC 152 ms
52,480 KB
testcase_23 AC 31 ms
53,980 KB
testcase_24 AC 115 ms
53,808 KB
testcase_25 AC 89 ms
5,728 KB
testcase_26 AC 298 ms
54,344 KB
testcase_27 AC 281 ms
6,156 KB
testcase_28 AC 10 ms
6,480 KB
testcase_29 AC 10 ms
6,404 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int n, m;
vector<int> g[20202];
bitset<20202> path[20202]; // last

bool solve() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	for (int i : g[0]) {
		for (int j : g[i]) if (j != 0) {
			path[j][i] = true;
		}
	}

	for (int i = 1; i < n; i++) {
		for (int j : g[i]) if (j != 0) {
			bool p1 = path[i][j];
			bool p2 = path[j][i];
			path[i][j] = false;
			path[j][i] = false;
			if (path[i].count() == 1 && path[j].count() == 1) {
				if ((path[i] & path[j]).none()) return true;
			} else if (path[i].count() >= 1 && path[j].count() >= 1) {
				return true;
			}
			path[i][j] = p1;
			path[j][i] = p2;
		}
	}

	return false;
}

int main() {
	puts(solve() ? "YES" : "NO");
}
0