結果
| 問題 |
No.1434 Make Maze
|
| コンテスト | |
| ユーザー |
convexineq
|
| 提出日時 | 2021-03-19 23:22:55 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,369 bytes |
| コンパイル時間 | 254 ms |
| コンパイル使用メモリ | 82,336 KB |
| 実行使用メモリ | 81,152 KB |
| 最終ジャッジ日時 | 2024-11-19 01:39:09 |
| 合計ジャッジ時間 | 5,637 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 RE * 13 |
ソースコード
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)))
convexineq