結果

問題 No.408 五輪ピック
ユーザー snrnsidysnrnsidy
提出日時 2021-06-15 01:12:28
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,042 bytes
コンパイル時間 2,137 ms
コンパイル使用メモリ 203,948 KB
実行使用メモリ 4,572 KB
最終ジャッジ日時 2023-08-26 15:40:43
合計ジャッジ時間 3,761 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 9 ms
4,380 KB
testcase_06 AC 36 ms
4,380 KB
testcase_07 AC 38 ms
4,376 KB
testcase_08 AC 8 ms
4,376 KB
testcase_09 AC 8 ms
4,380 KB
testcase_10 AC 37 ms
4,380 KB
testcase_11 AC 36 ms
4,376 KB
testcase_12 AC 43 ms
4,376 KB
testcase_13 AC 9 ms
4,376 KB
testcase_14 AC 14 ms
4,376 KB
testcase_15 AC 11 ms
4,420 KB
testcase_16 AC 10 ms
4,376 KB
testcase_17 AC 10 ms
4,384 KB
testcase_18 AC 10 ms
4,384 KB
testcase_19 AC 19 ms
4,380 KB
testcase_20 AC 19 ms
4,376 KB
testcase_21 AC 11 ms
4,376 KB
testcase_22 AC 32 ms
4,376 KB
testcase_23 AC 14 ms
4,572 KB
testcase_24 AC 29 ms
4,448 KB
testcase_25 AC 10 ms
4,392 KB
testcase_26 AC 78 ms
4,380 KB
testcase_27 WA -
testcase_28 AC 7 ms
4,380 KB
testcase_29 AC 7 ms
4,384 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

// 1 b c d e 1
int N, M, u, v;
bool check[20005];
vector <pair<int, int>> E;
vector <int> adj[20005];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> M;

	for (int i = 0; i < M; i++)
	{
		cin >> u >> v;
		E.push_back(make_pair(u, v));
		if (u == 1)
		{
			check[v] = true;
		}
		if (v == 1)
		{
			check[u] = true;
		}
	}

	for (int i = 0; i < M; i++)
	{
		u = E[i].first;
		v = E[i].second;
		if (check[u] && v!=1)
		{
			adj[v].push_back(u);
		}
		if (check[v] && u!=1)
		{
			adj[u].push_back(v);
		}
	}
	
	for (int i = 0; i < M; i++)
	{
		bitset <20005> check1, check2, temp;
		u = E[i].first;
		v = E[i].second;
		if (u == 1 || v == 1) continue;
		for (auto k : adj[u])
		{
			if (k == u || k == v) continue;
			check1[k] = true;
		}
		for (auto k : adj[v])
		{
			if (k == u || k == v) continue;
			check2[k] = true;
		}
		temp = (check1 | check2);
		if (temp.count() >= 2)
		{
			cout << "YES" << '\n';
			return 0;
		}
	}
	cout << "NO" << '\n';
	return 0;
}
0