結果

問題 No.1434 Make Maze
ユーザー KudeKude
提出日時 2021-03-19 23:11:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 1,027 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 84,480 KB
最終ジャッジ日時 2024-05-03 18:12:20
合計ジャッジ時間 6,335 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,096 KB
testcase_01 AC 36 ms
51,712 KB
testcase_02 AC 136 ms
84,480 KB
testcase_03 AC 136 ms
84,480 KB
testcase_04 AC 37 ms
52,352 KB
testcase_05 AC 36 ms
52,096 KB
testcase_06 AC 35 ms
51,968 KB
testcase_07 AC 37 ms
51,840 KB
testcase_08 AC 37 ms
52,480 KB
testcase_09 AC 37 ms
52,224 KB
testcase_10 AC 37 ms
52,096 KB
testcase_11 AC 37 ms
52,096 KB
testcase_12 AC 64 ms
72,576 KB
testcase_13 AC 40 ms
52,864 KB
testcase_14 AC 65 ms
70,912 KB
testcase_15 AC 87 ms
78,208 KB
testcase_16 AC 69 ms
74,368 KB
testcase_17 AC 68 ms
72,704 KB
testcase_18 AC 82 ms
77,440 KB
testcase_19 AC 100 ms
80,512 KB
testcase_20 AC 38 ms
52,224 KB
testcase_21 AC 37 ms
51,968 KB
testcase_22 AC 37 ms
52,096 KB
testcase_23 AC 43 ms
58,368 KB
testcase_24 AC 96 ms
79,488 KB
testcase_25 AC 111 ms
81,664 KB
testcase_26 AC 69 ms
73,472 KB
testcase_27 AC 97 ms
79,360 KB
testcase_28 AC 66 ms
74,368 KB
testcase_29 AC 52 ms
63,360 KB
testcase_30 AC 78 ms
77,568 KB
testcase_31 AC 91 ms
77,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w, x = map(int, input().split())
r = x - (h - 1) - (w - 1)
if r < 0 or r % 4:
    print(-1)
    exit()
r //= 4
s = [[(i | j) & 1 for j in range(w)] for i in range(h)]
for i in range(h):
    s[i][0] = 0
for j in range(w):
    s[h-1][j] = 0

di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]
def flip(i, j):
    for k in range(4):
        ni = i + di[k]
        nj = j + dj[k]
        s[ni][nj] ^= 1
i = h - 2
j = w - 2
if j == 1:
    i -= 2

while r and i > 0 and j > 0:
    r -= 1
    flip(i, j)
    if j == 1:
        i -= 4
    else:
        i -= 2
    if i < 0:
        j -= 4
        i = h - 2
        if j == 1:
            i -= 2
for i in range(0, h, 2):
    for j in range(0, w, 2):
        ok = False
        for k in range(4):
            ni = i + di[k]
            nj = j + dj[k]
            if 0 <= ni < h and 0 <= nj < w and s[ni][nj] == 0:
                ok = True
                break
        if not ok:
            s[i][j - 1] = 0
if r != 0:
    print(-1)
    exit()
for si in s:
    print(''.join('.#'[x] for x in si))
0