Submission #3733920
Source Code Expand
import std.algorithm; import std.array; import std.container; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readint = read!int; alias readints = reads!int; const N = 10; alias Loc = Tuple!(int, "row", int, "col"); Loc[] dxy(int row, int col) { Loc[] ret; auto a = [0, 1, 0, -1]; for (int i = 0; i < a.length; i++) { ret ~= Loc(row + a[i], col + a[$ - i - 1]); } return ret; } bool calc(int row, int col, string[] g) { auto a = new char[][](N, N); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { a[i][j] = g[i][j]; } } assert(a[row][col] == 'x'); a[row][col] = 'o'; auto q = new DList!int(row * 10 + col); while (!q.empty) { int x = q.front; q.removeFront(); int r = x / 10; int c = x % 10; if (a[r][c] == 'x') continue; a[r][c] = 'x'; foreach (loc; dxy(r, c)) { if (0 <= loc.row && loc.row < N && 0 <= loc.col && loc.col < N) { if (a[loc.row][loc.col] == 'o') { q.insertBack(loc.row * 10 + loc.col); } } } } // 陸地が全てなくなったか for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (a[i][j] == 'o') return false; } } return true; } void main() { string[] g; for (int i = 0; i < N; i++) g ~= read!string; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (g[i][j] == 'o') continue; if (calc(i, j, g)) { writeln("YES"); return; } } } writeln("NO"); }
Submission Info
Submission Time | |
---|---|
Task | B - 埋め立て |
User | noriok |
Language | D (DMD64 v2.070.1) |
Score | 100 |
Code Size | 1929 Byte |
Status | AC |
Exec Time | 3 ms |
Memory | 636 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 10_rand_00.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 10_rand_09.txt, 10_rand_10.txt, 10_rand_11.txt, 10_rand_12.txt, 10_rand_13.txt, 10_rand_14.txt, 10_rand_15.txt, 10_rand_16.txt, 10_rand_17.txt, 10_rand_18.txt, 10_rand_19.txt, 10_rand_20.txt, 10_rand_21.txt, 10_rand_22.txt, 10_rand_23.txt, 10_rand_24.txt, 10_rand_25.txt, 10_rand_26.txt, 10_rand_27.txt, 10_rand_28.txt, 10_rand_29.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 380 KB |
00_sample_01.txt | AC | 2 ms | 380 KB |
00_sample_02.txt | AC | 1 ms | 256 KB |
10_rand_00.txt | AC | 3 ms | 636 KB |
10_rand_01.txt | AC | 1 ms | 256 KB |
10_rand_02.txt | AC | 2 ms | 508 KB |
10_rand_03.txt | AC | 2 ms | 380 KB |
10_rand_04.txt | AC | 1 ms | 256 KB |
10_rand_05.txt | AC | 3 ms | 508 KB |
10_rand_06.txt | AC | 1 ms | 256 KB |
10_rand_07.txt | AC | 3 ms | 636 KB |
10_rand_08.txt | AC | 2 ms | 380 KB |
10_rand_09.txt | AC | 2 ms | 508 KB |
10_rand_10.txt | AC | 3 ms | 636 KB |
10_rand_11.txt | AC | 3 ms | 636 KB |
10_rand_12.txt | AC | 3 ms | 636 KB |
10_rand_13.txt | AC | 1 ms | 256 KB |
10_rand_14.txt | AC | 3 ms | 636 KB |
10_rand_15.txt | AC | 3 ms | 636 KB |
10_rand_16.txt | AC | 1 ms | 256 KB |
10_rand_17.txt | AC | 1 ms | 256 KB |
10_rand_18.txt | AC | 3 ms | 636 KB |
10_rand_19.txt | AC | 2 ms | 508 KB |
10_rand_20.txt | AC | 2 ms | 380 KB |
10_rand_21.txt | AC | 1 ms | 380 KB |
10_rand_22.txt | AC | 3 ms | 636 KB |
10_rand_23.txt | AC | 2 ms | 380 KB |
10_rand_24.txt | AC | 3 ms | 636 KB |
10_rand_25.txt | AC | 1 ms | 380 KB |
10_rand_26.txt | AC | 3 ms | 508 KB |
10_rand_27.txt | AC | 1 ms | 256 KB |
10_rand_28.txt | AC | 3 ms | 636 KB |
10_rand_29.txt | AC | 3 ms | 636 KB |