結果
問題 | No.1675 Strange Minimum Query |
ユーザー | gr1msl3y |
提出日時 | 2021-09-10 22:12:34 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,665 bytes |
コンパイル時間 | 275 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 123,792 KB |
最終ジャッジ日時 | 2024-06-12 00:34:22 |
合計ジャッジ時間 | 28,654 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
52,480 KB |
testcase_01 | AC | 39 ms
52,480 KB |
testcase_02 | AC | 39 ms
52,480 KB |
testcase_03 | AC | 689 ms
97,396 KB |
testcase_04 | AC | 702 ms
101,208 KB |
testcase_05 | AC | 271 ms
87,508 KB |
testcase_06 | AC | 721 ms
100,788 KB |
testcase_07 | AC | 894 ms
107,320 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 558 ms
120,448 KB |
testcase_14 | AC | 768 ms
123,792 KB |
testcase_15 | AC | 694 ms
123,720 KB |
testcase_16 | AC | 38 ms
52,480 KB |
testcase_17 | AC | 395 ms
87,148 KB |
testcase_18 | AC | 495 ms
89,200 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 1,060 ms
116,696 KB |
testcase_23 | AC | 891 ms
99,108 KB |
testcase_24 | AC | 830 ms
103,444 KB |
testcase_25 | AC | 662 ms
93,644 KB |
testcase_26 | WA | - |
testcase_27 | AC | 803 ms
110,596 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 1,081 ms
108,160 KB |
testcase_32 | AC | 1,379 ms
122,548 KB |
testcase_33 | AC | 1,307 ms
123,460 KB |
testcase_34 | AC | 1,450 ms
122,624 KB |
testcase_35 | AC | 1,347 ms
123,660 KB |
testcase_36 | AC | 1,290 ms
123,376 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-1).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)] for s in seq: if s == -INF: s = 1 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)