結果

問題 No.408 五輪ピック
ユーザー snrnsidysnrnsidy
提出日時 2021-06-14 23:36:47
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 650 bytes
コンパイル時間 2,042 ms
コンパイル使用メモリ 201,072 KB
実行使用メモリ 4,988 KB
最終ジャッジ日時 2023-08-26 13:11:01
合計ジャッジ時間 4,069 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 10 ms
4,472 KB
testcase_06 AC 9 ms
4,568 KB
testcase_07 AC 12 ms
4,736 KB
testcase_08 AC 9 ms
4,376 KB
testcase_09 AC 11 ms
4,412 KB
testcase_10 WA -
testcase_11 AC 8 ms
4,448 KB
testcase_12 AC 13 ms
4,756 KB
testcase_13 AC 11 ms
4,556 KB
testcase_14 WA -
testcase_15 AC 10 ms
4,448 KB
testcase_16 AC 12 ms
4,560 KB
testcase_17 AC 13 ms
4,636 KB
testcase_18 AC 15 ms
4,712 KB
testcase_19 AC 15 ms
4,816 KB
testcase_20 AC 5 ms
4,384 KB
testcase_21 AC 4 ms
4,384 KB
testcase_22 AC 8 ms
4,556 KB
testcase_23 AC 18 ms
4,928 KB
testcase_24 WA -
testcase_25 AC 10 ms
4,556 KB
testcase_26 AC 17 ms
4,988 KB
testcase_27 AC 10 ms
4,428 KB
testcase_28 AC 9 ms
4,380 KB
testcase_29 AC 9 ms
4,520 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

bool dp[6][20001];
vector <int> adj[20001];
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m, a, b;

	cin >> n >> m;

	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	dp[0][1] = true;

	for (int j = 0; j < 5; j++)
	{
		for (int k = 1; k <= n; k++)
		{
			if (dp[j][k] == false) continue;
			for (auto u : adj[k])
			{
				if (u == 1)
				{
					if(j+1==5) dp[j + 1][u] = true;
				}
				dp[j + 1][u] = true;
			}
		}
	}
	if (dp[5][1])
	{
		cout << "YES" << '\n';
		//return 0;
	}
	else
	{
		cout << "NO" << '\n';
	}
	return 0;
}
0