結果
問題 | No.2432 Flip and Move |
ユーザー | chineristAC |
提出日時 | 2023-08-18 23:07:51 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,634 bytes |
コンパイル時間 | 435 ms |
コンパイル使用メモリ | 82,452 KB |
実行使用メモリ | 764,764 KB |
最終ジャッジ日時 | 2024-05-06 05:40:34 |
合計ジャッジ時間 | 27,494 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
53,376 KB |
testcase_01 | AC | 41 ms
53,120 KB |
testcase_02 | AC | 803 ms
395,232 KB |
testcase_03 | TLE | - |
testcase_04 | AC | 121 ms
112,624 KB |
testcase_05 | AC | 119 ms
112,352 KB |
testcase_06 | AC | 243 ms
169,088 KB |
testcase_07 | MLE | - |
testcase_08 | MLE | - |
testcase_09 | TLE | - |
testcase_10 | AC | 482 ms
270,336 KB |
testcase_11 | AC | 536 ms
310,376 KB |
testcase_12 | AC | 321 ms
225,152 KB |
testcase_13 | AC | 320 ms
214,620 KB |
testcase_14 | AC | 376 ms
217,940 KB |
testcase_15 | MLE | - |
testcase_16 | AC | 402 ms
209,116 KB |
testcase_17 | AC | 891 ms
354,456 KB |
testcase_18 | AC | 263 ms
153,436 KB |
testcase_19 | AC | 678 ms
311,656 KB |
testcase_20 | AC | 1,013 ms
396,692 KB |
testcase_21 | AC | 722 ms
303,956 KB |
testcase_22 | AC | 720 ms
317,396 KB |
testcase_23 | AC | 236 ms
147,776 KB |
testcase_24 | AC | 888 ms
341,536 KB |
testcase_25 | AC | 613 ms
283,540 KB |
testcase_26 | AC | 400 ms
210,996 KB |
testcase_27 | AC | 99 ms
87,424 KB |
testcase_28 | AC | 94 ms
83,840 KB |
testcase_29 | AC | 712 ms
299,900 KB |
testcase_30 | AC | 1,041 ms
372,144 KB |
testcase_31 | AC | 402 ms
201,120 KB |
testcase_32 | AC | 114 ms
91,776 KB |
testcase_33 | AC | 1,025 ms
366,700 KB |
testcase_34 | AC | 430 ms
210,372 KB |
testcase_35 | AC | 277 ms
158,728 KB |
testcase_36 | AC | 40 ms
52,992 KB |
testcase_37 | AC | 39 ms
53,120 KB |
testcase_38 | AC | 40 ms
53,728 KB |
ソースコード
import sys from itertools import permutations from heapq import * input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) class SegmentTree: def __init__(self, init_val, segfunc, ide_ele): n = len(init_val) self.segfunc = segfunc self.ide_ele = ide_ele self.num = 1 << (n - 1).bit_length() self.tree = [ide_ele] * 2 * self.num self.size = n for i in range(n): self.tree[self.num + i] = init_val[i] for i in range(self.num - 1, 0, -1): self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1]) def update(self, k, x): k += self.num self.tree[k] = self.segfunc(self.tree[k],x) while k > 1: k >>= 1 self.tree[k] = self.segfunc(self.tree[2*k], self.tree[2*k+1]) def query(self, l, r): if r==self.size: r = self.num res = self.ide_ele l += self.num r += self.num right = [] while l < r: if l & 1: res = self.segfunc(res, self.tree[l]) l += 1 if r & 1: right.append(self.tree[r-1]) l >>= 1 r >>= 1 for e in right[::-1]: res = self.segfunc(res,e) return res H,W = mi() K = int(input()) visit = [[[-1]*W for i in range(H)] for d in range(4)] visit[0][0][0] = 0 trail = [(0,0,0)] loop_l = -1 while True: d,h,w = trail[-1] if d & 1 == 0: if h+1 < H: h += 1 else: d ^= 1 else: if 0 <= h-1: h -= 1 else: d ^= 1 if d & 2 == 0: if w+1 < W: w += 1 else: d ^= 2 else: if 0 <= w-1: w -= 1 else: d ^= 2 if visit[d][h][w] == -1: visit[d][h][w] = len(trail) trail.append((d,h,w)) else: loop_l = visit[d][h][w] break if K <= len(trail): res = [[0]*W for i in range(H)] for d,h,w in trail[:K]: res[h][w] ^= 1 for i in range(H): S = "".join(["." if res[i][j]==0 else "#" for j in range(W)]) print(S) exit() L = len(trail) - loop_l loop_cnt = (K-loop_l) // L add = trail[loop_l:loop_l+((K-loop_l)%L)] res = [[0]*W for i in range(H)] for d,h,w in trail[:loop_l]: res[h][w] ^= 1 for d,h,w in trail[loop_l:]: if L & 1: res[h][w] ^= 1 for d,h,w in add: res[h][w] ^= 1 for i in range(H): S = "".join(["." if res[i][j]==0 else "#" for j in range(W)]) print(S)