結果

問題 No.1434 Make Maze
ユーザー convexineqconvexineq
提出日時 2021-03-19 23:22:55
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,369 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 81,152 KB
最終ジャッジ日時 2024-04-29 19:10:17
合計ジャッジ時間 5,891 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,224 KB
testcase_01 AC 41 ms
52,096 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 42 ms
51,840 KB
testcase_06 AC 41 ms
52,480 KB
testcase_07 AC 41 ms
52,352 KB
testcase_08 RE -
testcase_09 AC 41 ms
52,224 KB
testcase_10 RE -
testcase_11 AC 42 ms
52,224 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 42 ms
51,712 KB
testcase_21 AC 43 ms
51,968 KB
testcase_22 AC 42 ms
51,840 KB
testcase_23 AC 41 ms
52,096 KB
testcase_24 AC 83 ms
78,976 KB
testcase_25 AC 93 ms
81,152 KB
testcase_26 AC 63 ms
65,920 KB
testcase_27 AC 85 ms
78,720 KB
testcase_28 AC 58 ms
64,512 KB
testcase_29 AC 50 ms
60,032 KB
testcase_30 AC 67 ms
68,992 KB
testcase_31 AC 71 ms
70,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h,w,x = map(int,input().split())
a,b = h//2+1,w//2+1
L = a+b-2
if a%2==0 and b%2==0:
    R = a*b-2
else:
    R = a*b-1
if x%2:
    print(-1)
    exit()
x //= 2
#print(a,b,L,x,R)
if x%2 != L%2 or not (L <= x <= R):
    print(-1)
    exit()

ans = [[0]*w for _ in range(h)]


def dist(i,j): return a+b-i-j-2
res = []
p,q,cnt = 0,0,0

if a%2:
    for i in range(h):
        for j in range(w):
            if i%2==0: ans[i][j] = 1

    while cnt + dist(p,q) != x:
        if p%2==0:
            if q != b-1: q += 1
            else:
                ans[2*p+1][2*q] = 1
                p += 1
                
        else:
            if q: q -= 1
            else:
                ans[2*p+1][2*q] = 1
                p += 1
        cnt += 1

    while p != a-1:
        ans[2*p+1][2*q] = 1
        p += 1

elif b%2:
    for i in range(h):
        for j in range(w):
            if j%2==0: ans[i][j] = 1

    while cnt + dist(p,q) != x:
        if q%2==0:
            if p != a-1: p += 1
            else:
                ans[2*p][2*q+1] = 1
                q += 1
                
        else:
            if p: p -= 1
            else:
                ans[2*p][2*q+1] = 1
                q += 1
        cnt += 1

    while q != b-1:
        ans[2*p][2*q+1] = 1
        q += 1

else:#ぐぐ
    assert 0

s = "#."
for ai in ans:
    print("".join(map(lambda i:s[i],ai)))
0