結果
問題 | No.1434 Make Maze |
ユーザー | convexineq |
提出日時 | 2021-03-19 23:36:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 91 ms / 2,000 ms |
コード長 | 2,651 bytes |
コンパイル時間 | 278 ms |
コンパイル使用メモリ | 82,164 KB |
実行使用メモリ | 84,264 KB |
最終ジャッジ日時 | 2024-05-03 18:17:29 |
合計ジャッジ時間 | 5,626 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
54,264 KB |
testcase_01 | AC | 35 ms
53,084 KB |
testcase_02 | AC | 91 ms
83,824 KB |
testcase_03 | AC | 87 ms
84,264 KB |
testcase_04 | AC | 35 ms
53,672 KB |
testcase_05 | AC | 37 ms
53,408 KB |
testcase_06 | AC | 34 ms
52,820 KB |
testcase_07 | AC | 34 ms
54,908 KB |
testcase_08 | AC | 35 ms
53,408 KB |
testcase_09 | AC | 36 ms
53,740 KB |
testcase_10 | AC | 34 ms
53,704 KB |
testcase_11 | AC | 33 ms
53,136 KB |
testcase_12 | AC | 49 ms
66,016 KB |
testcase_13 | AC | 37 ms
53,692 KB |
testcase_14 | AC | 48 ms
65,868 KB |
testcase_15 | AC | 61 ms
78,300 KB |
testcase_16 | AC | 49 ms
67,620 KB |
testcase_17 | AC | 49 ms
66,252 KB |
testcase_18 | AC | 54 ms
70,948 KB |
testcase_19 | AC | 66 ms
80,196 KB |
testcase_20 | AC | 39 ms
52,756 KB |
testcase_21 | AC | 35 ms
53,048 KB |
testcase_22 | AC | 41 ms
52,832 KB |
testcase_23 | AC | 40 ms
53,224 KB |
testcase_24 | AC | 67 ms
78,812 KB |
testcase_25 | AC | 77 ms
81,412 KB |
testcase_26 | AC | 51 ms
67,552 KB |
testcase_27 | AC | 65 ms
79,156 KB |
testcase_28 | AC | 48 ms
65,636 KB |
testcase_29 | AC | 42 ms
62,252 KB |
testcase_30 | AC | 51 ms
69,648 KB |
testcase_31 | AC | 55 ms
71,528 KB |
ソースコード
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:#ぐぐ 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 if p == a-2 and q == 0: break #print(p,q) if p != a-2 or q != 0: for i in range(h): for j in range(w): if i%2==0: ans[i][j] = 1 while p != a-1: ans[2*p+1][2*q] = 1 p += 1 else: for i in range(h-3): for j in range(w): if i%2==0: ans[i][j] = 1 for i in range(h-3,h): for j in range(w): if j%2==0: ans[i][j] = 1 while cnt + dist(p,q) != x: #print(p,q) if q%2==0: if p != a-1: p += 1 else: ans[2*p][2*q+1] = 1 q += 1 else: if p != a-2: p -= 1 else: ans[2*p][2*q+1] = 1 q += 1 cnt += 1 #print(p,q,b-1) while q != b-1: ans[2*p][2*q+1] = 1 q += 1 s = "#." for ai in ans: print("".join(map(lambda i:s[i],ai)))