結果
問題 | No.1023 Cyclic Tour |
ユーザー |
|
提出日時 | 2020-04-10 22:53:58 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 826 bytes |
コンパイル時間 | 1,019 ms |
コンパイル使用メモリ | 114,836 KB |
実行使用メモリ | 23,228 KB |
最終ジャッジ日時 | 2024-06-22 06:34:37 |
合計ジャッジ時間 | 11,854 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 WA * 18 |
ソースコード
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");}