結果
問題 | No.1434 Make Maze |
ユーザー | convexineq |
提出日時 | 2021-03-19 23:36:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 95 ms / 2,000 ms |
コード長 | 2,651 bytes |
コンパイル時間 | 336 ms |
コンパイル使用メモリ | 82,228 KB |
実行使用メモリ | 84,332 KB |
最終ジャッジ日時 | 2024-11-24 21:45:19 |
合計ジャッジ時間 | 5,884 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
53,236 KB |
testcase_01 | AC | 40 ms
53,632 KB |
testcase_02 | AC | 94 ms
84,332 KB |
testcase_03 | AC | 95 ms
84,268 KB |
testcase_04 | AC | 38 ms
52,772 KB |
testcase_05 | AC | 39 ms
53,360 KB |
testcase_06 | AC | 37 ms
53,120 KB |
testcase_07 | AC | 38 ms
54,420 KB |
testcase_08 | AC | 38 ms
53,764 KB |
testcase_09 | AC | 38 ms
53,384 KB |
testcase_10 | AC | 39 ms
53,416 KB |
testcase_11 | AC | 38 ms
53,320 KB |
testcase_12 | AC | 52 ms
65,904 KB |
testcase_13 | AC | 41 ms
54,308 KB |
testcase_14 | AC | 51 ms
65,556 KB |
testcase_15 | AC | 69 ms
78,296 KB |
testcase_16 | AC | 55 ms
66,860 KB |
testcase_17 | AC | 55 ms
66,428 KB |
testcase_18 | AC | 58 ms
70,748 KB |
testcase_19 | AC | 74 ms
80,340 KB |
testcase_20 | AC | 38 ms
52,940 KB |
testcase_21 | AC | 38 ms
52,992 KB |
testcase_22 | AC | 38 ms
53,476 KB |
testcase_23 | AC | 38 ms
53,384 KB |
testcase_24 | AC | 66 ms
79,024 KB |
testcase_25 | AC | 76 ms
81,200 KB |
testcase_26 | AC | 54 ms
67,056 KB |
testcase_27 | AC | 70 ms
78,884 KB |
testcase_28 | AC | 51 ms
65,888 KB |
testcase_29 | AC | 43 ms
61,740 KB |
testcase_30 | AC | 55 ms
69,780 KB |
testcase_31 | AC | 64 ms
71,604 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)))