結果
問題 | No.1023 Cyclic Tour |
ユーザー |
|
提出日時 | 2020-04-10 22:54:53 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 854 bytes |
コンパイル時間 | 771 ms |
コンパイル使用メモリ | 116,152 KB |
実行使用メモリ | 19,200 KB |
最終ジャッジ日時 | 2024-06-22 06:34:49 |
合計ジャッジ時間 | 7,271 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 12 WA * 4 TLE * 1 -- * 32 |
ソースコード
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"); }