結果
問題 | No.1675 Strange Minimum Query |
ユーザー | gr1msl3y |
提出日時 | 2021-09-10 21:46:27 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,615 bytes |
コンパイル時間 | 246 ms |
コンパイル使用メモリ | 82,224 KB |
実行使用メモリ | 124,160 KB |
最終ジャッジ日時 | 2024-06-11 23:18:11 |
合計ジャッジ時間 | 30,497 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
54,292 KB |
testcase_01 | AC | 37 ms
53,620 KB |
testcase_02 | AC | 39 ms
53,544 KB |
testcase_03 | AC | 726 ms
97,536 KB |
testcase_04 | AC | 739 ms
101,200 KB |
testcase_05 | AC | 289 ms
87,512 KB |
testcase_06 | AC | 764 ms
100,532 KB |
testcase_07 | AC | 969 ms
107,336 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 615 ms
120,556 KB |
testcase_14 | AC | 815 ms
124,052 KB |
testcase_15 | AC | 674 ms
124,160 KB |
testcase_16 | AC | 39 ms
54,136 KB |
testcase_17 | AC | 421 ms
87,528 KB |
testcase_18 | AC | 489 ms
88,936 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 1,168 ms
117,024 KB |
testcase_23 | AC | 987 ms
99,252 KB |
testcase_24 | AC | 935 ms
103,332 KB |
testcase_25 | AC | 745 ms
93,788 KB |
testcase_26 | WA | - |
testcase_27 | AC | 895 ms
110,544 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 1,191 ms
108,552 KB |
testcase_32 | AC | 1,543 ms
122,552 KB |
testcase_33 | AC | 1,485 ms
123,400 KB |
testcase_34 | AC | 1,462 ms
122,828 KB |
testcase_35 | AC | 1,352 ms
123,976 KB |
testcase_36 | AC | 1,349 ms
123,544 KB |
ソースコード
N, Q = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(Q)] for i in range(Q): A[i][0] -= 1 INF = 2*10**9 opX = max opY = max UnitX = -INF UnitY = -INF act = max class LazySegmentTree(): def __init__(self, n, opX, opY, UnitX, UnitY, A=None): self.s = 2**(n).bit_length() self.size = 2*self.s self.node = [UnitX]*self.size self.lazy = [UnitY]*self.size if A: for i in range(n): self.node[self.s+i] = A[i] for i in range(self.s-1, -1, -1): self.node[i] = opX(self.node[2*i], self.node[2*i+1]) def propagation(self, i): h = i.bit_length()-1 for n in range(h, 0, -1): j = i >> n if self.lazy[j] != UnitY: self.node[j] = act(self.node[j], self.lazy[j]) self.lazy[2*j] = opY(self.lazy[2*j], self.lazy[j]) self.lazy[2*j+1] = opY(self.lazy[2*j+1], self.lazy[j]) self.lazy[j] = UnitY def recalculate(self, i): while i > 1: i >>= 1 x = act(self.node[2*i], self.lazy[2*i]) y = act(self.node[2*i+1], self.lazy[2*i+1]) self.node[i] = opX(x, y) def update_range(self, L, R, a): L += self.s R += self.s L0 = L//(L & -L) R0 = R//(R & -R) self.propagation(L0) self.propagation(R0) while L < R: if L & 1: self.lazy[L] = opY(self.lazy[L], a) L += 1 if R & 1: R -= 1 self.lazy[R] = opY(self.lazy[R], a) L >>= 1 R >>= 1 self.recalculate(L0) self.recalculate(R0) def get_range(self, L, R): vL, vR = UnitX, UnitX L += self.s R += self.s L0 = L//(L & -L) R0 = R//(R & -R) self.propagation(L0) self.propagation(R0) while L < R: if L & 1: vL = opX(vL, act(self.node[L], self.lazy[L])) L += 1 if R & 1: R -= 1 vR = opX(act(self.node[R], self.lazy[R]), vR) L >>= 1 R >>= 1 return opX(vL, vR) state = LazySegmentTree(N, max, max, -INF, -INF) for l, r, v in A: state.update_range(l, r, v) seq = [state.get_range(i, i+1) for i in range(N)] opX = min opY = min UnitX = INF UnitY = INF act = min solve = LazySegmentTree(N, min, min, INF, INF, seq) for l, r, v in A: if solve.get_range(l, r) != v: print(-1) break else: print(*seq)