結果
| 問題 | No.640 76本のトロンボーン |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-12-10 13:15:24 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 1,569 bytes |
| 記録 | |
| コンパイル時間 | 824 ms |
| コンパイル使用メモリ | 119,296 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-13 02:10:14 |
| 合計ジャッジ時間 | 1,539 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;
void main() {
auto N = readln.chomp.to!int;
auto A = N.iota.map!(_ => readln.chomp.to!(dchar[])).array;
int ans = 0;
int[] rr = [0, 0, N-1, 0];
int[] cc = [0, 0, 0, N-1];
int[] dr = [0, 1, 0, 1];
int[] dc = [1, 0, 1, 0];
foreach (mask; 0..3^^4) {
int tmp = 0;
bool ok = true;
auto B = A.map!(a => a.dup).array;
foreach (i; 0..4) {
int sr = rr[i];
int sc = cc[i];
int k = mask % 3;
mask /= 3;
if (k == 1) {
sr += dr[i];
sc += dc[i];
} else if (k == 2) {
continue;
}
tmp += 1;
foreach (j; 0..N-1) {
if (B[sr][sc] == '#') {
ok = false;
break;
}
B[sr][sc] = '#';
sr += dr[i];
sc += dc[i];
}
}
if (!ok) continue;
int row = 0;
int col = 0;
foreach (i; 1..N-1) {
row += B[i][1..N-1].map!(x => x == '.').all && (B[i][0] == '.' || B[i][N-1] == '.');
}
foreach (j; 1..N-1) {
col += iota(1, N-1).map!(i => A[i][j] == '.').all && (B[0][j] == '.' || B[N-1][j] == '.');
}
ans = max(ans, tmp + max(row, col));
}
ans.writeln;
}