結果

問題 No.408 五輪ピック
コンテスト
ユーザー izuru_matsuura
提出日時 2016-10-18 18:04:02
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
WA  
実行時間 -
コード長 881 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,242 ms
コンパイル使用メモリ 117,268 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-05 07:50:21
合計ジャッジ時間 3,686 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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