結果
問題 | No.2650 [Cherry 6th Tune *] セイジャク |
ユーザー | miya145592 |
提出日時 | 2024-02-23 23:04:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,892 bytes |
コンパイル時間 | 304 ms |
コンパイル使用メモリ | 81,972 KB |
実行使用メモリ | 101,856 KB |
最終ジャッジ日時 | 2024-09-29 08:26:47 |
合計ジャッジ時間 | 21,701 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
52,480 KB |
testcase_01 | AC | 35 ms
52,992 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 476 ms
98,952 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
ソースコード
# https://qiita.com/ether2420/items/7b67b2b35ad5f441d686 def segfunc(x,y): return x 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 get(self,pos): pos+=self.num return self.tree[pos] import bisect import sys input = sys.stdin.readline N, A = map(int, input().split()) X = list(map(int, input().split())) T = int(input()) LR = [list(map(int, input().split())) for _ in range(T)] for i in range(N): x = X[i] X[i] = (x, i) X.sort() ST = LazySegTree_RUQ([0 for _ in range(N)], segfunc, 0) for t in range(T): l, r = LR[t] l_pos = bisect.bisect_left(X, (l, 0)) r_pos = bisect.bisect_left(X, (r, N)) if l_pos==r_pos: continue ST.update(l_pos, r_pos, t+1) ans = [-1 for _ in range(N)] for i in range(N): tmp = ST.get(i) x, idx = X[i] if tmp==0: ans[idx] = -1 else: ans[idx] = tmp for a in ans: print(a)