結果

問題 No.483 マッチ並べ
ユーザー izuru_matsuuraizuru_matsuura
提出日時 2017-04-11 19:01:23
言語 D
(dmd 2.107.1)
結果
WA  
実行時間 -
コード長 1,630 bytes
コンパイル時間 1,450 ms
コンパイル使用メモリ 143,356 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-03 12:44:51
合計ジャッジ時間 3,106 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 WA -
testcase_26 AC 1 ms
4,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
4,376 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 1 ms
4,380 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 1 ms
4,380 KB
testcase_49 AC 1 ms
4,380 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 1 ms
4,376 KB
testcase_52 AC 1 ms
4,380 KB
testcase_53 AC 1 ms
4,376 KB
testcase_54 WA -
testcase_55 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 = 5;

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縺ー繧サ繝シ繝・////
            foreach (next; G[p]) {
                if (next == prev) continue;
                if (next !in used) 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");

}
0