結果

問題 No.179 塗り分け
ユーザー nanaenanae
提出日時 2017-12-11 21:29:10
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,693 bytes
コンパイル時間 952 ms
コンパイル使用メモリ 95,932 KB
実行使用メモリ 4,512 KB
最終ジャッジ日時 2023-09-03 17:28:20
合計ジャッジ時間 4,677 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 8 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 35 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 36 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 39 ms
4,380 KB
testcase_21 AC 39 ms
4,376 KB
testcase_22 AC 38 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 36 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 WA -
testcase_27 AC 51 ms
4,384 KB
testcase_28 WA -
testcase_29 AC 60 ms
4,376 KB
testcase_30 WA -
testcase_31 AC 65 ms
4,376 KB
testcase_32 AC 19 ms
4,380 KB
testcase_33 AC 57 ms
4,384 KB
testcase_34 WA -
testcase_35 AC 60 ms
4,384 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 4 ms
4,380 KB
testcase_44 AC 9 ms
4,380 KB
testcase_45 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.d(12): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`

ソースコード

diff #

import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int h, w;
    scan(h, w);

    auto map = new int[][](h, w);
    foreach (i ; 0 .. h) {
        string s = readln.chomp;
        foreach (int j, ch; s) {
            if (ch == '.') {
                map[i][j] = 1;
            }
        }
    }

    foreach (x ; 0 .. h) {
        foreach (y ; 0 .. w) {
            if (x + y == 0) continue;

            bool ok = 1;
            auto m = new int[][](h, w);
            iota(h).each!(i => m[i] = map[i].dup);

            foreach (i ; 0 .. h) {
                foreach (j ; 0 .. w) {
                    if (m[i][j]) continue;

                    m[i][j] = 2;

                    if (i + x >= h || j + y >= w || m[i+x][j+y]) {
                        ok = 0;
                    }
                    else {
                        m[i + x][j + y] = 3;
                    }
                }
            }

            if (ok) {
                debug {
                    writefln("%(%(%s %)\n%)", m);
                    writeln(x, " ", y);
                }
                writeln("YES");
                return;
            }
        }
    }

    writeln("NO");
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
0