結果
問題 | No.2432 Flip and Move |
ユーザー | chineristAC |
提出日時 | 2023-08-18 23:17:07 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,893 bytes |
コンパイル時間 | 274 ms |
コンパイル使用メモリ | 13,184 KB |
実行使用メモリ | 466,676 KB |
最終ジャッジ日時 | 2024-11-28 10:11:54 |
合計ジャッジ時間 | 75,789 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 34 ms
16,512 KB |
testcase_01 | AC | 35 ms
272,896 KB |
testcase_02 | TLE | - |
testcase_03 | TLE | - |
testcase_04 | AC | 399 ms
47,872 KB |
testcase_05 | AC | 375 ms
371,968 KB |
testcase_06 | AC | 1,325 ms
89,728 KB |
testcase_07 | TLE | - |
testcase_08 | TLE | - |
testcase_09 | TLE | - |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | AC | 1,793 ms
466,676 KB |
testcase_14 | AC | 1,948 ms
143,232 KB |
testcase_15 | TLE | - |
testcase_16 | AC | 1,942 ms
115,840 KB |
testcase_17 | TLE | - |
testcase_18 | AC | 1,038 ms
79,360 KB |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | AC | 961 ms
66,560 KB |
testcase_24 | TLE | - |
testcase_25 | TLE | - |
testcase_26 | AC | 1,967 ms
125,568 KB |
testcase_27 | AC | 153 ms
24,064 KB |
testcase_28 | AC | 122 ms
254,720 KB |
testcase_29 | TLE | - |
testcase_30 | TLE | - |
testcase_31 | AC | 1,797 ms
112,384 KB |
testcase_32 | AC | 332 ms
27,392 KB |
testcase_33 | TLE | - |
testcase_34 | TLE | - |
testcase_35 | AC | 1,049 ms
76,672 KB |
testcase_36 | AC | 33 ms
11,264 KB |
testcase_37 | AC | 32 ms
11,136 KB |
testcase_38 | AC | 32 ms
221,056 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 = [[[0]*W for i in range(H)] for d in range(4)] visit[0][0][0] = 0 trail = [(0,0)] loop_l = -1 while True: d,pos = trail[-1] h,w = pos//W,pos % W 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] == 0: visit[d][h][w] = 1 trail.append((d,h*W+w)) else: loop_l = trail.index((d,h*W+w)) break assert len(trail) <= 4 * H * W if K <= len(trail): for i in range(H): for j in range(W): visit[0][i][j] = 0 res = visit[0] for d,pos in trail[:K]: h,w = pos//W,pos % W 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 for i in range(H): for j in range(W): visit[0][i][j] = 0 res = visit[0] for d,pos in trail[:loop_l]: h,w = pos//W,pos%W res[h][w] ^= 1 for d,pos in trail[loop_l:]: h,w = pos//W,pos%W if L & 1: res[h][w] ^= 1 for d,pos in trail[loop_l:loop_l+((K-loop_l)%L)]: h,w = pos//W,pos%W res[h][w] ^= 1 for i in range(H): S = "".join(["." if res[i][j]==0 else "#" for j in range(W)]) print(S)