Submission #298401
Source Code Expand
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// 1:未訪問土地 2: 訪問済み
int[][] defField = new int[10][10];
for (int i = 0; i < 10; i++) {
String line = sc.nextLine();
for (int j = 0; j < 10; j++) {
defField[i][j] = line.charAt(j) == 'o' ? 1 : 0;
}
}
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
if (defField[i][j] == 0) {
int[][] newField = new int[10][10];
// copy
for (int x = 0; x < 10; x++) {
for (int y = 0; y < 10; y++) {
newField[x][y] = defField[x][y];
}
}
newField[i][j] = 2;
walk(newField, i, j);
if (check(newField)) {
System.out.println("YES");
return;
}
}
}
}
System.out.println("NO");
}
public static boolean check(int[][] field) {
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
if (field[i][j] == 1) {
return false;
}
}
}
return true;
}
public static void walk(int[][] field, int x, int y) {
field[x][y] = 2;
if (x > 0 && field[x - 1][y] == 1) {
walk(field, x - 1, y);
}
if (x < 9 && field[x + 1][y] == 1) {
walk(field, x + 1, y);
}
if (y > 0 && field[x][y - 1] == 1) {
walk(field, x, y - 1);
}
if (y < 9 && field[x][y + 1] == 1) {
walk(field, x, y + 1);
}
}
//
// public static void printDebug(int[][] field) {
// for (int x = 0; x < 10; x++) {
// for (int y = 0; y < 10; y++) {
// System.out.print(field[x][y]);
// }
// System.out.println();
// }
// }
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - 埋め立て |
| User | fdash06 |
| Language | Java (OpenJDK 1.7.0) |
| Score | 100 |
| Code Size | 2249 Byte |
| Status | AC |
| Exec Time | 430 ms |
| Memory | 20964 KiB |
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 | 420 ms | 20852 KiB |
| 00_sample_01.txt | AC | 417 ms | 20900 KiB |
| 00_sample_02.txt | AC | 413 ms | 20896 KiB |
| 10_rand_00.txt | AC | 421 ms | 20900 KiB |
| 10_rand_01.txt | AC | 430 ms | 20936 KiB |
| 10_rand_02.txt | AC | 417 ms | 20916 KiB |
| 10_rand_03.txt | AC | 418 ms | 20856 KiB |
| 10_rand_04.txt | AC | 429 ms | 20840 KiB |
| 10_rand_05.txt | AC | 418 ms | 20896 KiB |
| 10_rand_06.txt | AC | 409 ms | 20808 KiB |
| 10_rand_07.txt | AC | 416 ms | 20920 KiB |
| 10_rand_08.txt | AC | 417 ms | 20880 KiB |
| 10_rand_09.txt | AC | 423 ms | 20908 KiB |
| 10_rand_10.txt | AC | 425 ms | 20896 KiB |
| 10_rand_11.txt | AC | 417 ms | 20808 KiB |
| 10_rand_12.txt | AC | 428 ms | 20888 KiB |
| 10_rand_13.txt | AC | 425 ms | 20904 KiB |
| 10_rand_14.txt | AC | 419 ms | 20876 KiB |
| 10_rand_15.txt | AC | 416 ms | 20916 KiB |
| 10_rand_16.txt | AC | 416 ms | 20836 KiB |
| 10_rand_17.txt | AC | 415 ms | 20860 KiB |
| 10_rand_18.txt | AC | 417 ms | 20896 KiB |
| 10_rand_19.txt | AC | 414 ms | 20892 KiB |
| 10_rand_20.txt | AC | 419 ms | 20824 KiB |
| 10_rand_21.txt | AC | 418 ms | 20928 KiB |
| 10_rand_22.txt | AC | 424 ms | 20964 KiB |
| 10_rand_23.txt | AC | 413 ms | 20840 KiB |
| 10_rand_24.txt | AC | 417 ms | 20900 KiB |
| 10_rand_25.txt | AC | 418 ms | 20960 KiB |
| 10_rand_26.txt | AC | 419 ms | 20872 KiB |
| 10_rand_27.txt | AC | 422 ms | 20780 KiB |
| 10_rand_28.txt | AC | 417 ms | 20888 KiB |
| 10_rand_29.txt | AC | 415 ms | 20764 KiB |