結果

問題 No.408 五輪ピック
ユーザー snrnsidy
提出日時 2021-06-14 23:36:47
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 650 bytes
コンパイル時間 2,095 ms
コンパイル使用メモリ 195,616 KB
最終ジャッジ日時 2025-01-22 08:18:33
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27 WA * 5
権限があれば一括ダウンロードができます

ソースコード

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