提出 #72889515
ソースコード 拡げる
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
if (!sc.hasNextInt()) return;
int T = sc.nextInt();
while (T-- > 0) {
int N = sc.nextInt();
int C = sc.nextInt() - 1;
char[][] grid = new char[N][N];
for (int i = 0; i < N; i++) {
grid[i] = sc.next().toCharArray();
}
boolean[] reachable = new boolean[N];
reachable[C] = true;
boolean[] allWallsBelowReached = new boolean[N];
Arrays.fill(allWallsBelowReached, true);
for (int r = N - 1; r > 0; r--) {
for (int c = 0; c < N; c++) {
if (grid[r][c] == '#' && !reachable[c]) {
allWallsBelowReached[c] = false;
}
}
boolean[] nextReach = new boolean[N];
for (int c = 0; c < N; c++) {
boolean canTransition = false;
if (reachable[c]) canTransition = true;
if (c > 0 && reachable[c - 1]) canTransition = true;
if (c < N - 1 && reachable[c + 1]) canTransition = true;
if (canTransition) {
if (grid[r - 1][c] == '.' || allWallsBelowReached[c]) {
nextReach[c] = true;
}
}
}
reachable = nextReach;
}
StringBuilder sb = new StringBuilder();
for (boolean b : reachable) sb.append(b ? '1' : '0');
System.out.println(sb.toString());
}
}
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | E - Climbing Silver |
| ユーザ | addy |
| 言語 | Java24 (OpenJDK 24.0.2) |
| 得点 | 450 |
| コード長 | 1863 Byte |
| 結果 | AC |
| 実行時間 | 1139 ms |
| メモリ | 104724 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 450 / 450 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | sample_01.txt |
| All | sample_01.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt, test_47.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| sample_01.txt | AC | 81 ms | 40968 KiB |
| test_01.txt | AC | 455 ms | 69100 KiB |
| test_02.txt | AC | 526 ms | 73504 KiB |
| test_03.txt | AC | 585 ms | 76472 KiB |
| test_04.txt | AC | 645 ms | 75308 KiB |
| test_05.txt | AC | 755 ms | 76384 KiB |
| test_06.txt | AC | 823 ms | 77760 KiB |
| test_07.txt | AC | 809 ms | 75868 KiB |
| test_08.txt | AC | 884 ms | 76896 KiB |
| test_09.txt | AC | 931 ms | 76556 KiB |
| test_10.txt | AC | 997 ms | 76524 KiB |
| test_11.txt | AC | 936 ms | 71924 KiB |
| test_12.txt | AC | 1082 ms | 77124 KiB |
| test_13.txt | AC | 1139 ms | 77852 KiB |
| test_14.txt | AC | 748 ms | 71944 KiB |
| test_15.txt | AC | 544 ms | 71752 KiB |
| test_16.txt | AC | 553 ms | 67632 KiB |
| test_17.txt | AC | 585 ms | 104380 KiB |
| test_18.txt | AC | 552 ms | 104724 KiB |
| test_19.txt | AC | 591 ms | 104268 KiB |
| test_20.txt | AC | 582 ms | 104360 KiB |
| test_21.txt | AC | 574 ms | 104436 KiB |
| test_22.txt | AC | 522 ms | 104056 KiB |
| test_23.txt | AC | 516 ms | 104420 KiB |
| test_24.txt | AC | 407 ms | 95216 KiB |
| test_25.txt | AC | 528 ms | 104044 KiB |
| test_26.txt | AC | 417 ms | 95404 KiB |
| test_27.txt | AC | 415 ms | 96404 KiB |
| test_28.txt | AC | 433 ms | 96464 KiB |
| test_29.txt | AC | 579 ms | 104332 KiB |
| test_30.txt | AC | 455 ms | 95240 KiB |
| test_31.txt | AC | 541 ms | 104500 KiB |
| test_32.txt | AC | 595 ms | 104292 KiB |
| test_33.txt | AC | 453 ms | 96524 KiB |
| test_34.txt | AC | 577 ms | 104200 KiB |
| test_35.txt | AC | 452 ms | 95532 KiB |
| test_36.txt | AC | 457 ms | 95964 KiB |
| test_37.txt | AC | 428 ms | 95900 KiB |
| test_38.txt | AC | 420 ms | 96256 KiB |
| test_39.txt | AC | 424 ms | 95876 KiB |
| test_40.txt | AC | 455 ms | 96592 KiB |
| test_41.txt | AC | 595 ms | 104392 KiB |
| test_42.txt | AC | 418 ms | 95568 KiB |
| test_43.txt | AC | 414 ms | 95864 KiB |
| test_44.txt | AC | 564 ms | 104068 KiB |
| test_45.txt | AC | 567 ms | 104348 KiB |
| test_46.txt | AC | 416 ms | 96936 KiB |
| test_47.txt | AC | 521 ms | 104412 KiB |