結果
問題 | No.408 五輪ピック |
ユーザー | izuru_matsuura |
提出日時 | 2016-10-18 18:11:43 |
言語 | D (dmd 2.106.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,023 bytes |
コンパイル時間 | 1,524 ms |
コンパイル使用メモリ | 141,664 KB |
実行使用メモリ | 34,320 KB |
最終ジャッジ日時 | 2023-09-02 22:22:48 |
合計ジャッジ時間 | 14,221 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,372 KB |
testcase_01 | AC | 1 ms
4,368 KB |
testcase_02 | AC | 2 ms
4,372 KB |
testcase_03 | AC | 1 ms
4,368 KB |
testcase_04 | AC | 1 ms
4,372 KB |
testcase_05 | AC | 3,038 ms
29,992 KB |
testcase_06 | AC | 23 ms
4,372 KB |
testcase_07 | AC | 36 ms
6,332 KB |
testcase_08 | AC | 270 ms
25,208 KB |
testcase_09 | AC | 86 ms
12,264 KB |
testcase_10 | WA | - |
testcase_11 | AC | 24 ms
4,572 KB |
testcase_12 | AC | 50 ms
9,676 KB |
testcase_13 | AC | 1,925 ms
31,060 KB |
testcase_14 | WA | - |
testcase_15 | TLE | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
ソースコード
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; } alias S = Tuple!(int, "index", int, "depth", int, "prev"); bool[S] D; D[S(0, 0, -1)] = true; DList!S Q; Q.insert(S(0, 0, -1)); while (!Q.empty) { auto c = Q.front; Q.removeFront; int v = c[0]; int d = c[1]; int prev = c[2]; if (d >= 5) continue; foreach (nv; G[v]) { if (nv == prev) continue; int nd = d + 1; if (S(nv, nd, v) in D) continue; D[S(nv, nd, v)] = true; Q.insert(S(nv, nd, v)); } } foreach (k, v; D) { if (k.index == 0 && k.depth == 5) { writeln("YES"); return; } } writeln("NO"); }