結果

問題 No.408 五輪ピック
ユーザー Ymgch_KYmgch_K
提出日時 2018-01-16 21:09:18
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,147 bytes
コンパイル時間 583 ms
コンパイル使用メモリ 57,980 KB
実行使用メモリ 5,684 KB
最終ジャッジ日時 2023-08-25 19:52:31
合計ジャッジ時間 3,438 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 12 ms
4,376 KB
testcase_06 AC 11 ms
5,044 KB
testcase_07 AC 14 ms
4,736 KB
testcase_08 AC 10 ms
4,376 KB
testcase_09 AC 12 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 10 ms
4,376 KB
testcase_12 AC 16 ms
4,692 KB
testcase_13 AC 12 ms
4,380 KB
testcase_14 WA -
testcase_15 AC 12 ms
4,376 KB
testcase_16 AC 13 ms
4,376 KB
testcase_17 AC 15 ms
4,380 KB
testcase_18 AC 17 ms
4,380 KB
testcase_19 AC 18 ms
4,732 KB
testcase_20 AC 6 ms
4,380 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 10 ms
4,960 KB
testcase_23 AC 26 ms
5,684 KB
testcase_24 AC 16 ms
5,516 KB
testcase_25 AC 11 ms
4,376 KB
testcase_26 AC 20 ms
5,524 KB
testcase_27 AC 11 ms
4,380 KB
testcase_28 AC 12 ms
4,380 KB
testcase_29 AC 11 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

struct state { int node, prev, step; };

int main() {
        int n, m;
        scanf("%d%d", &n, &m);
        vector<vector<int>> g(n);
        for (int i = 0; i < m; i ++) {
                int a, b;
                scanf("%d%d", &a, &b);
                a --, b --;
                g[a].push_back(b);
                g[b].push_back(a);
        }
        vector<vector<bool>> used(n, vector<bool> (6));
        queue<state> q;
        q.push({ 0, -1, 0 });
        used[0][0] = true;
        while (!q.empty()) {
                state p = q.front(); q.pop();
                int u = p.node;
                int s = p.step;
                int prev = p.prev;
                if (s == 5) continue;
                for (auto v : g[u]) if (!used[v][s + 1]) {
                        if (v == prev) continue;
                        if (s + 1 != 5 && v == 0) continue;
                        used[v][s + 1] = true;
                        q.push({v, u,  s + 1});
                }
        }
        puts(used[0][5] ? "YES" : "NO");
        return 0;
}

0