結果
問題 | No.483 マッチ並べ |
ユーザー |
![]() |
提出日時 | 2017-04-11 19:07:25 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,538 bytes |
コンパイル時間 | 1,188 ms |
コンパイル使用メモリ | 144,676 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-12 18:39:34 |
合計ジャッジ時間 | 2,317 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 WA * 12 |
ソースコード
import std.algorithm; import std.array; import std.ascii; import std.container; import std.conv; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.typecons; void log(A...)(A arg) { stderr.writeln(arg); } int size(T)(in T s) { return cast(int)s.length; } const int[] dy = [-1, 0, 1, 0]; const int[] dx = [0, 1, 0, -1]; struct Point { int y, x; } const Z = 120; void main() { int N; readf("%d\n", &N); Point[][Point] G; foreach (i; 0 .. N) { int sy, sx, gy, gx; readf("%d %d %d %d\n", &sy, &sx, &gy, &gx); G[Point(sy, sx)] ~= Point(gy, gx); G[Point(gy, gx)] ~= Point(sy, sx); } bool[Point] used; bool dfs(in Point p, in Point prev) { if (p in used) { // 繧ゅ←縺」縺ヲ譚・縺溘i縲∵悴菴ソ逕ィ縺ョ霎コ縺梧ョ九▲縺ヲ縺・l縺ー繧「繧ヲ繝医∵ョ九▲縺ヲ縺・↑縺代l縺ー繧サ繝シ繝・//// if (G[p].length >= 3) return false; return true; } used[p] = true; foreach (next; G[p]) { if (next == prev) continue; if (! dfs(next, p)) return false; } return true; } foreach (int y; 0 .. Z) { foreach (int x; 0 .. Z) { if (Point(y, x) !in G) continue; used.clear(); if (! dfs(Point(y, x), Point(-1, -1))) { writeln("NO"); return; } } } writeln("YES"); }