結果

問題 No.1023 Cyclic Tour
ユーザー nebukuro09nebukuro09
提出日時 2020-04-10 22:54:53
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 854 bytes
コンパイル時間 1,118 ms
コンパイル使用メモリ 102,408 KB
実行使用メモリ 18,392 KB
最終ジャッジ日時 2023-09-04 07:17:02
合計ジャッジ時間 8,190 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,884 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 127 ms
13,436 KB
testcase_05 AC 128 ms
12,676 KB
testcase_06 AC 146 ms
13,404 KB
testcase_07 AC 135 ms
12,644 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 113 ms
13,692 KB
testcase_12 AC 106 ms
14,160 KB
testcase_13 AC 96 ms
13,944 KB
testcase_14 WA -
testcase_15 AC 104 ms
14,216 KB
testcase_16 AC 194 ms
13,180 KB
testcase_17 AC 204 ms
12,668 KB
testcase_18 AC 210 ms
12,612 KB
testcase_19 AC 196 ms
12,704 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdlib;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto G = new int[][](N);
    foreach (i; 0..M) {
        s = readln.split.map!(to!int);
        auto u = s[0] - 1;
        auto v = s[1] - 1;
        auto c = s[2];
        G[u] ~= v;
        if (c == 1) G[v] ~= u;
    }

    auto visited = new bool[](N);

    bool dfs(int n, int p) {
        if (visited[n]) return true;
        visited[n] = true;
        foreach (m; G[n]) {
            if (p == m) continue;
            if (dfs(m, n)) return true;
        }
        visited[n] = false;
        return false;
    }

    writeln(dfs(0, -1) ? "Yes" : "No");
}
0