結果
問題 | No.2809 Sort Query |
ユーザー | hato336 |
提出日時 | 2024-07-12 22:41:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,088 bytes |
コンパイル時間 | 416 ms |
コンパイル使用メモリ | 82,268 KB |
実行使用メモリ | 298,944 KB |
最終ジャッジ日時 | 2024-07-12 22:43:04 |
合計ジャッジ時間 | 76,581 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
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 | AC | 701 ms
245,372 KB |
testcase_12 | AC | 747 ms
247,880 KB |
testcase_13 | WA | - |
testcase_14 | AC | 682 ms
245,292 KB |
testcase_15 | AC | 672 ms
245,228 KB |
testcase_16 | AC | 678 ms
245,324 KB |
testcase_17 | AC | 685 ms
245,472 KB |
testcase_18 | AC | 664 ms
244,668 KB |
testcase_19 | AC | 712 ms
245,548 KB |
testcase_20 | AC | 737 ms
249,036 KB |
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 | WA | - |
testcase_31 | AC | 687 ms
204,888 KB |
testcase_32 | AC | 661 ms
204,828 KB |
testcase_33 | AC | 657 ms
205,292 KB |
testcase_34 | AC | 650 ms
204,620 KB |
testcase_35 | AC | 676 ms
204,748 KB |
testcase_36 | AC | 700 ms
248,752 KB |
testcase_37 | AC | 686 ms
248,916 KB |
testcase_38 | AC | 661 ms
248,988 KB |
testcase_39 | AC | 668 ms
248,700 KB |
testcase_40 | AC | 684 ms
248,768 KB |
testcase_41 | AC | 1,214 ms
230,688 KB |
testcase_42 | AC | 1,173 ms
231,020 KB |
testcase_43 | AC | 1,170 ms
230,472 KB |
testcase_44 | AC | 1,125 ms
230,880 KB |
testcase_45 | AC | 1,126 ms
231,088 KB |
testcase_46 | AC | 1,000 ms
230,648 KB |
testcase_47 | AC | 1,021 ms
230,348 KB |
testcase_48 | AC | 1,046 ms
230,352 KB |
testcase_49 | AC | 1,042 ms
230,792 KB |
testcase_50 | AC | 1,029 ms
230,168 KB |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | AC | 137 ms
89,104 KB |
ソースコード
import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random #sys.setrecursionlimit(10**9) #sys.set_int_max_str_digits(0) #input = sys.stdin.readline #n = int(input()) # #alist = [] #https://github.com/shakayami/ACL-for-python/blob/master/segtree.py class segtree(): n=1 size=1 log=2 d=[0] op=None e=10**15 def __init__(self,V,OP,E): self.n=len(V) self.op=OP self.e=E self.log=(self.n-1).bit_length() self.size=1<<self.log self.d=[E for i in range(2*self.size)] for i in range(self.n): self.d[self.size+i]=V[i] for i in range(self.size-1,0,-1): self.update(i) def set(self,p,x): assert 0<=p and p<self.n p+=self.size self.d[p]=x for i in range(1,self.log+1): self.update(p>>i) def get(self,p): assert 0<=p and p<self.n return self.d[p+self.size] def prod(self,l,r): assert 0<=l and l<=r and r<=self.n sml=self.e smr=self.e l+=self.size r+=self.size while(l<r): if (l&1): sml=self.op(sml,self.d[l]) l+=1 if (r&1): smr=self.op(self.d[r-1],smr) r-=1 l>>=1 r>>=1 return self.op(sml,smr) def all_prod(self): return self.d[1] def max_right(self,l,f): assert 0<=l and l<=self.n assert f(self.e) if l==self.n: return self.n l+=self.size sm=self.e while(1): while(l%2==0): l>>=1 if not(f(self.op(sm,self.d[l]))): while(l<self.size): l=2*l if f(self.op(sm,self.d[l])): sm=self.op(sm,self.d[l]) l+=1 return l-self.size sm=self.op(sm,self.d[l]) l+=1 if (l&-l)==l: break return self.n def min_left(self,r,f): assert 0<=r and r<=self.n assert f(self.e) if r==0: return 0 r+=self.size sm=self.e while(1): r-=1 while(r>1 and (r%2)): r>>=1 if not(f(self.op(self.d[r],sm))): while(r<self.size): r=(2*r+1) if f(self.op(self.d[r],sm)): sm=self.op(self.d[r],sm) r-=1 return r+1-self.size sm=self.op(self.d[r],sm) if (r& -r)==r: break return 0 def update(self,k): self.d[k]=self.op(self.d[2*k],self.d[2*k+1]) def __str__(self): return str([self.get(i) for i in range(self.n)]) input = sys.stdin.readline n,q = map(int,input().split()) a = list(map(int,input().split())) check = set([0 for i in range(n)]) query = [] b = a[:] for i in range(q): t = list(map(int,input().split())) query.append(t) if t[0] == 1: b.append(t[2]) b = list(set(b)) b.sort() d = {b[i]:i for i in range(len(b))} st = segtree([0 for i in range(len(b))],operator.add,0) for i in a: st.set(d[i],st.get(d[i])+1) lazy = [] for i in range(q): t = query[i] if t[0] == 3: t,k,= t k -= 1 if k in check: print(a[k]) else: def f(z): if z < k+1: return 1 else: return 0 def g(z): if z >= 1: return 0 else: return 1 y = st.max_right(0,f) y = st.min_left(y,g) print(b[y]) elif t[0] == 2: for k,x,y in lazy: st.set(d[y],st.get(d[y])-1) st.set(d[x],st.get(d[x])+1) lazy.clear() check.clear() elif t[0] == 1: t,k,x = t lazy.append((k-1,x,a[k-1])) a[k-1] = x check.add(k-1)