結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-11 21:41:22 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 245 ms / 3,000 ms |
| コード長 | 1,836 bytes |
| コンパイル時間 | 672 ms |
| コンパイル使用メモリ | 106,920 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 23:00:49 |
| 合計ジャッジ時間 | 5,161 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
コンパイルメッセージ
Main.d(14): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
ソースコード
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);
int kuro = h*w;
foreach (i ; 0 .. h) {
string s = readln.chomp;
foreach (int j, ch; s) {
if (ch == '.') {
map[i][j] = 1;
kuro--;
}
}
}
if (kuro==0){
writeln("NO");
return;
}
foreach (x ; -h .. h) {
foreach (y ; -w .. w) {
if (x == 0 && 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 < 0 || i + x >= h || j + y < 0 || 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);
}
}
}