package main import ( "bufio" "fmt" "os" ) func main() { // https://yukicoder.me/problems/no/2265 // !给定一个长为2的幂次的数组 // 1 x y 将s[x]变为y // 2 left right indexXor 字符串s[i^indexXor](left<=i> 1 data := make([][]S, H+1) for i := range data { data[i] = make([]S, size) } for i := range nums { data[0][i] = nums[i] } res.n, res.log, res.size = n, log, size res.data = data res.h = H res.unit = res.e() for h := 1; h <= H; h++ { for i := 0; i < n>>h; i++ { res._update(h, i) } } return res } func (st *XorSegTree) Get(i int) S { return st.data[0][i] } func (st *XorSegTree) Set(i int, x S) { st.data[0][i] = x for h := 1; h <= st.h; h++ { i >>= 1 st._update(h, i) } } func (st *XorSegTree) Update(i int, x S) { st.data[0][i] = st.op(st.data[0][i], x) for h := 1; h <= st.h; h++ { i >>= 1 st._update(h, i) } } // Calculate prod_{l<=i= end { break } if start&(1< 0; exp >>= 1 { if exp&1 == 1 { res = res * base % mod } base = base * base % mod } return res }