結果
問題 | No.2395 区間二次変換一点取得 |
ユーザー | Mao-beta |
提出日時 | 2024-08-19 13:57:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 531 ms / 2,000 ms |
コード長 | 5,508 bytes |
コンパイル時間 | 609 ms |
コンパイル使用メモリ | 82,292 KB |
実行使用メモリ | 96,236 KB |
最終ジャッジ日時 | 2024-08-19 13:57:34 |
合計ジャッジ時間 | 7,690 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 56 ms
66,168 KB |
testcase_01 | AC | 57 ms
65,584 KB |
testcase_02 | AC | 55 ms
66,764 KB |
testcase_03 | AC | 56 ms
66,468 KB |
testcase_04 | AC | 56 ms
66,436 KB |
testcase_05 | AC | 54 ms
66,300 KB |
testcase_06 | AC | 55 ms
66,540 KB |
testcase_07 | AC | 57 ms
66,708 KB |
testcase_08 | AC | 57 ms
67,932 KB |
testcase_09 | AC | 63 ms
69,536 KB |
testcase_10 | AC | 70 ms
72,792 KB |
testcase_11 | AC | 153 ms
80,980 KB |
testcase_12 | AC | 223 ms
83,568 KB |
testcase_13 | AC | 528 ms
96,152 KB |
testcase_14 | AC | 505 ms
95,672 KB |
testcase_15 | AC | 512 ms
96,072 KB |
testcase_16 | AC | 531 ms
96,236 KB |
testcase_17 | AC | 501 ms
95,520 KB |
testcase_18 | AC | 348 ms
95,552 KB |
testcase_19 | AC | 354 ms
95,312 KB |
ソースコード
import sys import math import bisect from heapq import heapify, heappop, heappush from collections import deque, defaultdict, Counter from functools import lru_cache from itertools import accumulate, combinations, permutations, product sys.set_int_max_str_digits(10 ** 6) sys.setrecursionlimit(1000000) MOD = 10 ** 9 + 7 MOD99 = 998244353 input = lambda: sys.stdin.readline().strip() NI = lambda: int(input()) NMI = lambda: map(int, input().split()) NLI = lambda: list(NMI()) SI = lambda: input() SMI = lambda: input().split() SLI = lambda: list(SMI()) EI = lambda m: [NLI() for _ in range(m)] class lazy_segtree(): def update(self,k):self.d[k]=self.op(self.d[2*k],self.d[2*k+1]) def all_apply(self,k,f): self.d[k]=self.mapping(f,self.d[k]) if (k<self.size):self.lz[k]=self.composition(f,self.lz[k]) def push(self,k): self.all_apply(2*k,self.lz[k]) self.all_apply(2*k+1,self.lz[k]) self.lz[k]=self.identity def __init__(self,V,OP,E,MAPPING,COMPOSITION,ID): self.n=len(V) self.log=(self.n-1).bit_length() self.size=1<<self.log self.d=[E for i in range(2*self.size)] self.lz=[ID for i in range(self.size)] self.e=E self.op=OP self.mapping=MAPPING self.composition=COMPOSITION self.identity=ID 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 for i in range(self.log,0,-1):self.push(p>>i) 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 p+=self.size for i in range(self.log,0,-1):self.push(p>>i) return self.d[p] def prod(self,l,r): assert 0<=l and l<=r and r<=self.n if l==r:return self.e l+=self.size r+=self.size for i in range(self.log,0,-1): if (((l>>i)<<i)!=l):self.push(l>>i) if (((r>>i)<<i)!=r):self.push(r>>i) sml,smr=self.e,self.e while(l<r): if l&1: sml=self.op(sml,self.d[l]) l+=1 if r&1: r-=1 smr=self.op(self.d[r],smr) l>>=1 r>>=1 return self.op(sml,smr) def all_prod(self):return self.d[1] def apply_point(self,p,f): assert 0<=p and p<self.n p+=self.size for i in range(self.log,0,-1):self.push(p>>i) self.d[p]=self.mapping(f,self.d[p]) for i in range(1,self.log+1):self.update(p>>i) def apply(self,l,r,f): assert 0<=l and l<=r and r<=self.n if l==r:return l+=self.size r+=self.size for i in range(self.log,0,-1): if (((l>>i)<<i)!=l):self.push(l>>i) if (((r>>i)<<i)!=r):self.push((r-1)>>i) l2,r2=l,r while(l<r): if (l&1): self.all_apply(l,f) l+=1 if (r&1): r-=1 self.all_apply(r,f) l>>=1 r>>=1 l,r=l2,r2 for i in range(1,self.log+1): if (((l>>i)<<i)!=l):self.update(l>>i) if (((r>>i)<<i)!=r):self.update((r-1)>>i) def max_right(self,l,g): assert 0<=l and l<=self.n assert g(self.e) if l==self.n:return self.n l+=self.size for i in range(self.log,0,-1):self.push(l>>i) sm=self.e while(1): while(l%2==0):l>>=1 if not(g(self.op(sm,self.d[l]))): while(l<self.size): self.push(l) l=(2*l) if (g(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,g): assert (0<=r and r<=self.n) assert g(self.e) if r==0:return 0 r+=self.size for i in range(self.log,0,-1):self.push((r-1)>>i) sm=self.e while(1): r-=1 while(r>1 and (r%2)):r>>=1 if not(g(self.op(self.d[r],sm))): while(r<self.size): self.push(r) r=(2*r+1) if g(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 # 区間最小値取得(prod)・区間加算(apply) INF = 1<<60 def op(x, y): return min(x, y) # opの単位元 E = INF def mapping(f, a): # f: 作用する、a: 作用される return f + a def composition(f, g): # f(g()) return f + g # mappingの単位元 ID = 0 def main(): N, B, Q = NMI() LMR = EI(Q) X = [0] * (10**5+3) Y = [0] * (10**5+3) Z = [0] * (10**5+3) X[0] = 1 Y[0] = 1 Z[0] = 1 for i in range(10**5+1): X[i+1] = (X[i] + 1) % B Y[i+1] = (3*Y[i] + 2*X[i+1]*Z[i]) % B Z[i+1] = (3*Z[i]) % B seg = lazy_segtree([0]*N, op, E, mapping, composition, ID) for l, m, r in LMR: l -= 1 m -= 1 seg.apply(l, r, 1) c = seg.get(m) print(X[c], Y[c], Z[c]) if __name__ == "__main__": main()