結果

問題 No.1434 Make Maze
ユーザー shotoyooshotoyoo
提出日時 2021-03-19 23:42:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,178 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 98,176 KB
最終ジャッジ日時 2024-04-29 19:40:48
合計ジャッジ時間 5,938 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
52,352 KB
testcase_01 AC 35 ms
52,224 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 35 ms
52,736 KB
testcase_05 AC 34 ms
52,352 KB
testcase_06 AC 34 ms
52,224 KB
testcase_07 AC 33 ms
52,352 KB
testcase_08 WA -
testcase_09 AC 33 ms
52,352 KB
testcase_10 AC 34 ms
52,736 KB
testcase_11 WA -
testcase_12 RE -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 RE -
testcase_19 WA -
testcase_20 AC 33 ms
52,352 KB
testcase_21 AC 32 ms
52,096 KB
testcase_22 AC 35 ms
52,480 KB
testcase_23 AC 34 ms
52,352 KB
testcase_24 RE -
testcase_25 WA -
testcase_26 WA -
testcase_27 RE -
testcase_28 RE -
testcase_29 WA -
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")

U = 0
D = 1
L = 2
R = 3
d = {
    U: "U",
    D:"D",
    L:"L",
    R:"R"
}
H,W,x = list(map(int, input().split()))
h = (H+1)//2
w = (W+1)//2
M = h*w if h*w%4==0 else h*w-1
if not (H+W-2<=x<=2*(M-1) and x%2==0 and (x-(H+W-2))%4==0):
    print(-1)
else:
    ans = [[0]*W for _ in range(H)]
    for i in range(1,H,2):
        for j in range(1,W,2):
            ans[i][j] = 1
    for i in range(H):
        for j in range(1,W,2):
            ans[i][j] = 1
    vals = []
    def sub0(h,w,v):
        if w==2:
            if v%2==1:
                return None
            nokori = h-1
            i = 0
            j = W-2
            while v>0:
                v -= 4
                vals.extend([R, D, L, D])
                ans[i][j] = 0
                ans[i+2][j] = 0
                ans[i+1][j-1] = 1
                ans[i+3][j+1] = 1
                nokori -= 1
                i += 4
            for _ in range(nokori):
                vals.append(D)
            vals.append(R)
            ans[-1][W-2] = 0
            return 0
        else:
            vals.extend([D]*(h-1)+[R])
            ans[-1][W-2*(w-1)] = 0
#             print(vals, W-2*(w-1))
            return sub1(h,w-1,v)
    def sub1(h,w,v):
        if v==0:
            vals.extend([R]*(w-1))
            for j in range(W-2*(w-1), W):
                ans[-1][j] = 0
            return 0
        elif v<=2*(h-1):
#             assert w>=2 and v%2==0
            vv = v//2
            vals.extend([U]*vv)
            vals.append(R)
            vals.extend([D]*vv)
            vals.extend([R]*(w-2))
            ans[H-1-vv*2][W-2*w+2] = 0
#             print(vv)
            for j in range(W-2*w+4,W):
                ans[-1][j] = 0
            return 0
        else:
            vals.extend([U]*(h-1))
            vals.append([R])
            ans[0][W-2*(w-1)] = 0
            return sub0(h,w-1,v-(h-1))
    v = x//2-(h-1+w-1)
    sub0(h,w,v)
    for l in ans:
        write("".join(["#" if l[i] else "." for i in range(len(l))]))
0