結果
| 問題 |
No.408 五輪ピック
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-14 23:33:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 657 bytes |
| コンパイル時間 | 3,000 ms |
| コンパイル使用メモリ | 194,732 KB |
| 最終ジャッジ日時 | 2025-01-22 08:18:15 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 WA * 5 |
ソースコード
#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);
}
for (int i = 1; i <= 1; i++)
{
memset(dp, false, sizeof(dp));
dp[0][i] = 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])
{
dp[j + 1][u] = true;
}
}
}
if (dp[5][i])
{
cout << "YES" << '\n';
return 0;
}
}
cout << "NO" << '\n';
return 0;
}