結果

問題 No.1434 Make Maze
ユーザー KudeKude
提出日時 2021-03-19 23:11:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 1,027 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 85,584 KB
最終ジャッジ日時 2023-08-16 09:26:37
合計ジャッジ時間 9,152 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,348 KB
testcase_01 AC 69 ms
71,080 KB
testcase_02 AC 164 ms
85,488 KB
testcase_03 AC 161 ms
85,584 KB
testcase_04 AC 70 ms
71,584 KB
testcase_05 AC 70 ms
71,304 KB
testcase_06 AC 69 ms
71,244 KB
testcase_07 AC 69 ms
71,196 KB
testcase_08 AC 70 ms
71,300 KB
testcase_09 AC 70 ms
71,048 KB
testcase_10 AC 71 ms
71,420 KB
testcase_11 AC 71 ms
71,444 KB
testcase_12 AC 92 ms
76,980 KB
testcase_13 AC 72 ms
71,308 KB
testcase_14 AC 93 ms
77,016 KB
testcase_15 AC 113 ms
79,580 KB
testcase_16 AC 99 ms
78,052 KB
testcase_17 AC 100 ms
78,164 KB
testcase_18 AC 104 ms
78,488 KB
testcase_19 AC 131 ms
81,652 KB
testcase_20 AC 69 ms
71,264 KB
testcase_21 AC 70 ms
71,304 KB
testcase_22 AC 71 ms
71,300 KB
testcase_23 AC 75 ms
75,472 KB
testcase_24 AC 121 ms
80,448 KB
testcase_25 AC 134 ms
82,904 KB
testcase_26 AC 98 ms
78,008 KB
testcase_27 AC 124 ms
80,384 KB
testcase_28 AC 98 ms
77,896 KB
testcase_29 AC 82 ms
76,668 KB
testcase_30 AC 105 ms
78,516 KB
testcase_31 AC 111 ms
78,800 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