結果
問題 | No.1434 Make Maze |
ユーザー | ks2m |
提出日時 | 2021-03-19 22:48:31 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,911 bytes |
コンパイル時間 | 2,420 ms |
コンパイル使用メモリ | 77,304 KB |
実行使用メモリ | 43,724 KB |
最終ジャッジ日時 | 2024-04-29 18:11:11 |
合計ジャッジ時間 | 10,139 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 113 ms
40,972 KB |
testcase_01 | AC | 114 ms
40,172 KB |
testcase_02 | AC | 199 ms
43,380 KB |
testcase_03 | AC | 183 ms
43,724 KB |
testcase_04 | AC | 103 ms
40,372 KB |
testcase_05 | AC | 97 ms
39,828 KB |
testcase_06 | AC | 110 ms
41,100 KB |
testcase_07 | AC | 99 ms
40,096 KB |
testcase_08 | WA | - |
testcase_09 | AC | 114 ms
41,152 KB |
testcase_10 | AC | 116 ms
41,448 KB |
testcase_11 | AC | 118 ms
40,152 KB |
testcase_12 | AC | 120 ms
41,400 KB |
testcase_13 | AC | 115 ms
41,352 KB |
testcase_14 | AC | 107 ms
40,404 KB |
testcase_15 | AC | 161 ms
41,480 KB |
testcase_16 | AC | 125 ms
41,080 KB |
testcase_17 | AC | 120 ms
41,284 KB |
testcase_18 | AC | 135 ms
40,440 KB |
testcase_19 | AC | 156 ms
41,960 KB |
testcase_20 | AC | 113 ms
41,272 KB |
testcase_21 | AC | 110 ms
41,144 KB |
testcase_22 | AC | 116 ms
41,180 KB |
testcase_23 | AC | 119 ms
41,152 KB |
testcase_24 | AC | 173 ms
42,380 KB |
testcase_25 | AC | 175 ms
42,720 KB |
testcase_26 | AC | 142 ms
41,520 KB |
testcase_27 | AC | 158 ms
41,480 KB |
testcase_28 | AC | 103 ms
40,152 KB |
testcase_29 | AC | 112 ms
40,908 KB |
testcase_30 | AC | 139 ms
41,404 KB |
testcase_31 | AC | 130 ms
41,200 KB |
ソースコード
import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int h = sc.nextInt(); int w = sc.nextInt(); int x = sc.nextInt(); sc.close(); int min = h + w - 2; int max = h * (w / 2 + 1) + (w / 2) - 1; if (h % 4 == 3 && w % 4 == 3) { max -= Math.min(h, w) - 1; } int y = max - x; if (x < min || max < x || y % 4 != 0) { System.out.println(-1); return; } y /= 4; char[][] s = new char[h][w]; for (int i = 0; i < h; i++) { Arrays.fill(s[i], '.'); } for (int i = 1; i < h; i += 2) { for (int j = 1; j < w; j += 2) { s[i][j] = '#'; } } boolean tate = true; if (w % 4 == 3) { if (h % 4 == 1 || h > w) { tate = false; } } if (tate) { tate(s, h, w, y); } else { yoko(s, h, w, y); } PrintWriter pw = new PrintWriter(System.out); for (int i = 0; i < h; i++) { pw.println(s[i]); } pw.flush(); } static void tate(char[][] s, int h, int w, int y) { for (int j = 1; j < w; j += 4) { s[0][j] = '#'; } for (int i = 2; i < h - 1; i += 2) { for (int j = 1; j < w; j += 2) { s[i][j] = '#'; } } for (int j = 3; j < w; j += 4) { s[h - 1][j] = '#'; } int i = h - 1; int j = 1; for (int k = 0; k < y; k++) { s[i][j] = '#'; s[i - 2][j] = '.'; i -= 2; if (i < 2) { i = h - 1; j += 4; } } } static void yoko(char[][] s, int h, int w, int y) { for (int i = 1; i < h; i += 4) { s[i][0] = '#'; } for (int j = 2; j < w - 1; j += 2) { for (int i = 1; i < h; i += 2) { s[i][j] = '#'; } } for (int i = 3; i < h; i += 4) { s[i][w - 1] = '#'; } int j = w - 1; int i = 1; for (int k = 0; k < y; k++) { s[i][j] = '#'; s[i][j - 2] = '.'; j -= 2; if (j < 2) { j = w - 1; i += 4; } } } }