[백준 2934번] LRH 식물 (Python3)
import sys input = sys.stdin.readline def update(v,a,b,s,e,x): if a==s and b==e: seg[x] += v return mid = (s+e)//2 if b mid: update(v,a,b,mid+1,e,x*2+1) else: update(v,a,mid,s,mid,x*2) update(v,mid+1,b,mid+1,e,x*2+1) def cal(n,s,e,x): if s==e: return seg[x] mid = (s+e)//2 if n
[백준 12844번] XOR (Python3)
import sys input = sys.stdin.readline def make(s,e,x): if s==e: seg[x] = seq[s] else: mid = (s+e)//2 seg[x] = make(s,mid,x*2)^make(mid+1,e,x*2+1) return seg[x] def update(i,j,v,s,e,x): if (j-i+1)%2: seg[x] ^= v if (e-s+1)%2: seg[x] ^= lazy[x] if s!=e: lazy[x*2] ^= lazy[x]; lazy[x*2+1] ^= lazy[x] lazy[x] = 0 if i==s and j==e: if s!=e: lazy[x*2] ^= v; lazy[x*2+1] ^= v return seg[x] mid = (s+e)//2 ..