結果

問題 No.1023 Cyclic Tour
ユーザー nebukuro09nebukuro09
提出日時 2020-04-10 22:53:58
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 826 bytes
コンパイル時間 1,029 ms
コンパイル使用メモリ 100,872 KB
実行使用メモリ 23,724 KB
最終ジャッジ日時 2023-09-04 07:16:49
合計ジャッジ時間 12,919 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 127 ms
13,140 KB
testcase_05 AC 125 ms
13,976 KB
testcase_06 AC 142 ms
13,700 KB
testcase_07 AC 132 ms
13,444 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 114 ms
12,648 KB
testcase_12 AC 104 ms
13,712 KB
testcase_13 AC 95 ms
12,588 KB
testcase_14 WA -
testcase_15 AC 101 ms
13,116 KB
testcase_16 AC 195 ms
14,364 KB
testcase_17 AC 201 ms
13,128 KB
testcase_18 AC 208 ms
13,716 KB
testcase_19 AC 196 ms
13,972 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 220 ms
12,652 KB
testcase_23 WA -
testcase_24 AC 221 ms
12,596 KB
testcase_25 AC 231 ms
13,124 KB
testcase_26 AC 231 ms
12,740 KB
testcase_27 AC 220 ms
23,724 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 222 ms
13,672 KB
testcase_34 AC 219 ms
13,432 KB
testcase_35 AC 234 ms
12,652 KB
testcase_36 WA -
testcase_37 AC 212 ms
13,900 KB
testcase_38 WA -
testcase_39 AC 221 ms
13,924 KB
testcase_40 AC 218 ms
12,656 KB
testcase_41 WA -
testcase_42 AC 238 ms
13,964 KB
testcase_43 WA -
testcase_44 AC 134 ms
13,716 KB
testcase_45 AC 115 ms
21,096 KB
testcase_46 AC 114 ms
21,360 KB
testcase_47 AC 122 ms
20,620 KB
testcase_48 WA -
testcase_49 AC 212 ms
14,364 KB
testcase_50 WA -
testcase_51 AC 224 ms
13,948 KB
testcase_52 AC 226 ms
13,380 KB
権限があれば一括ダウンロードができます

ソースコード

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;
        }
        return false;
    }

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