結果

問題 No.408 五輪ピック
ユーザー izuru_matsuuraizuru_matsuura
提出日時 2016-10-18 18:04:02
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 881 bytes
コンパイル時間 1,402 ms
コンパイル使用メモリ 139,256 KB
実行使用メモリ 7,644 KB
最終ジャッジ日時 2023-09-02 22:22:02
合計ジャッジ時間 4,419 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 1 ms
4,368 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 42 ms
4,980 KB
testcase_06 AC 25 ms
4,368 KB
testcase_07 AC 38 ms
4,660 KB
testcase_08 AC 34 ms
4,368 KB
testcase_09 AC 34 ms
4,372 KB
testcase_10 WA -
testcase_11 AC 24 ms
4,368 KB
testcase_12 AC 43 ms
4,760 KB
testcase_13 AC 42 ms
4,564 KB
testcase_14 WA -
testcase_15 AC 42 ms
4,368 KB
testcase_16 AC 46 ms
4,980 KB
testcase_17 AC 49 ms
6,008 KB
testcase_18 AC 49 ms
5,772 KB
testcase_19 AC 52 ms
5,544 KB
testcase_20 AC 13 ms
4,376 KB
testcase_21 AC 8 ms
4,368 KB
testcase_22 AC 21 ms
4,372 KB
testcase_23 AC 65 ms
7,644 KB
testcase_24 WA -
testcase_25 AC 42 ms
5,836 KB
testcase_26 AC 52 ms
5,096 KB
testcase_27 AC 42 ms
5,520 KB
testcase_28 AC 30 ms
6,092 KB
testcase_29 AC 29 ms
6,072 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.typecons;
import std.string;
import std.array;
import std.conv;
import std.container;

void main() {
    int N, M;
    readf("%d %d\n", &N, &M);
    auto G = new int[][](N);
    foreach (i; 0 .. M) {
        int a, b;
        readf("%d %d\n", &a, &b);
        a--; b--;
        G[a] ~= b;
        G[b] ~= a;
    }

    auto D = new bool[][](N, 6);
    foreach (i; 0 .. N) D[i][] = false;
    D[0][0] = true;
    alias S = Tuple!(int, int);
    DList!S Q;
    Q.insert(S(0, 0));
    while (!Q.empty) {
        auto c = Q.front; Q.removeFront;
        int v = c[0];
        int d = c[1];
        D[v][d] = true;
        if (d >= 5) continue;
        foreach (nv; G[v]) {
            int nd = d + 1;
            if (D[nv][nd]) continue;
            D[nv][nd] = true;
            Q.insert(S(nv, nd));
        }
    }
    writeln(D[0][5] ? "YES" : "NO");
}
0