結果
問題 | No.1675 Strange Minimum Query |
ユーザー | stng |
提出日時 | 2021-09-10 23:28:47 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,840 bytes |
コンパイル時間 | 309 ms |
コンパイル使用メモリ | 82,080 KB |
実行使用メモリ | 127,952 KB |
最終ジャッジ日時 | 2024-06-12 04:32:02 |
合計ジャッジ時間 | 38,856 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 34 ms
52,964 KB |
testcase_01 | AC | 33 ms
53,232 KB |
testcase_02 | AC | 35 ms
53,684 KB |
testcase_03 | AC | 1,043 ms
96,972 KB |
testcase_04 | AC | 971 ms
104,472 KB |
testcase_05 | AC | 220 ms
84,252 KB |
testcase_06 | AC | 1,169 ms
100,460 KB |
testcase_07 | AC | 1,294 ms
114,140 KB |
testcase_08 | AC | 45 ms
62,456 KB |
testcase_09 | AC | 119 ms
76,812 KB |
testcase_10 | AC | 715 ms
101,872 KB |
testcase_11 | AC | 362 ms
92,752 KB |
testcase_12 | AC | 797 ms
102,764 KB |
testcase_13 | AC | 899 ms
119,952 KB |
testcase_14 | AC | 1,288 ms
126,308 KB |
testcase_15 | AC | 1,010 ms
127,952 KB |
testcase_16 | AC | 32 ms
53,420 KB |
testcase_17 | AC | 457 ms
85,864 KB |
testcase_18 | AC | 568 ms
87,176 KB |
testcase_19 | AC | 744 ms
98,076 KB |
testcase_20 | AC | 1,395 ms
106,632 KB |
testcase_21 | AC | 1,219 ms
105,608 KB |
testcase_22 | AC | 1,494 ms
113,208 KB |
testcase_23 | AC | 1,249 ms
97,864 KB |
testcase_24 | AC | 1,116 ms
99,528 KB |
testcase_25 | AC | 898 ms
92,792 KB |
testcase_26 | AC | 577 ms
89,968 KB |
testcase_27 | AC | 1,132 ms
103,964 KB |
testcase_28 | AC | 683 ms
96,288 KB |
testcase_29 | AC | 563 ms
95,676 KB |
testcase_30 | AC | 569 ms
89,988 KB |
testcase_31 | AC | 1,632 ms
105,096 KB |
testcase_32 | TLE | - |
testcase_33 | TLE | - |
testcase_34 | TLE | - |
testcase_35 | AC | 1,880 ms
126,596 KB |
testcase_36 | AC | 1,810 ms
126,448 KB |
ソースコード
class LazySegTree_RUQ: 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.lazy = [None]*2*self.num 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 gindex(self,l,r): l += self.num r += self.num lm = l>>(l&-l).bit_length() rm = r>>(r&-r).bit_length() while r>l: if l<=lm: yield l if r<=rm: yield r r >>= 1 l >>= 1 while l: yield l l >>= 1 def propagates(self,*ids): for i in reversed(ids): v = self.lazy[i] if v is None: continue self.lazy[i] = None self.lazy[2*i] = v self.lazy[2*i+1] = v self.tree[2*i] = v self.tree[2*i+1] = v def update(self,l,r,x): ids = self.gindex(l,r) self.propagates(*self.gindex(l,r)) l += self.num r += self.num while l<r: if l&1: self.lazy[l] = x self.tree[l] = x l += 1 if r&1: self.lazy[r-1] = x self.tree[r-1] = x r >>= 1 l >>= 1 for i in ids: self.tree[i] = self.segfunc(self.tree[2*i], self.tree[2*i+1]) def query(self,l,r): ids = self.gindex(l,r) self.propagates(*self.gindex(l,r)) res = self.ide_ele l += self.num r += self.num while l<r: if l&1: res = self.segfunc(res,self.tree[l]) l += 1 if r&1: res = self.segfunc(res,self.tree[r-1]) l >>= 1 r >>= 1 return res def main(): #####segfunc##### def segfunc(x, y): return min(x, y) ################# #####ide_ele##### ide_ele = 10**9 ################# n,q = map(int,input().split()) lr = [[int(i)-1 for i in input().split()] for j in range(q)] lr.sort(key = lambda x:x[2]) a = [10**9]*n seg = LazySegTree_RUQ(a, segfunc=segfunc, ide_ele=ide_ele) for i in range(q): #lo = seg.query(lr[i][0],lr[i][1]+1) seg.update(lr[i][0],lr[i][1]+1,lr[i][2]+1) for i in range(q): b = seg.query(lr[i][0],lr[i][1]+1) if b != lr[i][2]+1: print(-1) exit() b = [10**9]*n for i in range(n): b[i] = seg.query(i,i+1) print(*b) if __name__ == '__main__': main()