Well.. What tree-like array sets the Chairman tree? It's probably a data structure that can be modified and supported by prefix subtraction ...
Hey. Can be offline? Why don't you go to the team?
Oh also want to change, then three-dimensional Mo team is good,happy ending!
1 /**************************************************************2 problem:21203 User:rausen4 language:c++5 result:accepted6 time:488 Ms7 memory:5540 KB8 ****************************************************************/9 Ten#include <cstdio> One#include <cmath> A#include <algorithm> - - using namespacestd; the Const intN = 1e4 +5; - Const intCnt_c = 1e6 +5; - Const intMaxLen = N * *; - + intN, M, Sz, Cnt_b; - intW[n], c[n], pre[n]; + intNow ; A intCnt_c, cnt_q; at intAns[n], vis[n], cnt[cnt_c]; - CharBuf[maxlen], *ch =buf; - intLen; - - structOper_change { - intx, y, pre; in Oper_change () {} -Oper_change (int_x,int_y,int_p): X (_x), Y (_y), pre (_p) {} to } Oc[n]; + - structOper_query { the intx, y, id, t; * oper_query () {} $Oper_query (int_x,int_y,int_i,int_t): X (_x), Y (_y), id (_i), T (_t) {}Panax Notoginseng -InlineBOOL operator< (ConstOper_query &x)Const { the returnW[X] = = w[x.x]? W[y] = = w[x.y]? T < X.t:w[y] < W[X.Y]: W[x] <w[x.x]; + } A } Oq[n]; the +InlineintRead () { - intx =0; $ while(*ch <'0'||'9'< *ch) + +ch; $ while('0'<= *ch && *ch <='9') -x = x *Ten+ *ch-'0', ++ch; - returnx; the } - WuyiInlinevoidReverseintp) { the if(Vis[p]) { - if((--cnt[c[p]) = =0) --Now ; Wu}Else { - if((++cnt[c[p]) = =1) ++Now ; About } $VIS[P] ^=1; - } - -InlineintUpdateintPintC) { A if(Vis[p]) { + reverse (p); theC[P] =C; - reverse (p); $}ElseC[P] =C; the } the the intMain () { theLen = fread (CH,1, MaxLen, stdin); -Buf[len] =' /'; in intI, J, L, R, X, y; the Charop; then = Read (), M =read (); AboutSZ = (int) POW (n,2.0/3); the if(!sz) Sz =1; the for(i =1; I <= N; ++i) { theC[i] = Pre[i] =read (); + if(i% Sz = =1|| SZ = =1) ++Cnt_b; -W[i] =Cnt_b; the }Bayi for(i =1; I <= m; ++i) { the while(*ch! ='Q'&& *ch! ='R') ++ch; theOP = *ch; -x = Read (), y =read (); - if(OP = ='R') theOc[++cnt_c] = Oper_change (x, Y, pre[x]), pre[x] =y; the Else { the if(X >y) Swap (x, y); theOQ[++CNT_Q] =oper_query (x, Y, cnt_q, cnt_c); - } the } theSort (OQ +1, OQ + cnt_q +1); the for(i = L =1, R = oq[0].t =0; I <= cnt_q; ++i) {94 for(j = oq[i-1].T +1; J <= oq[i].t; ++j) Update (oc[j].x, OC[J].Y); the for(j = oq[i-1].t; J > oq[i].t; --j) Update (oc[j].x, oc[j].pre); the while(R < OQ[I].Y) Reverse (+ +R); the while(R > Oq[i].y) reverse (r--);98 while(L > oq[i].x) reverse (--l); About while(L < oq[i].x) reverse (l++); -Ans[oq[i].id] =Now ;101 }102 for(i =1; I <= cnt_q; ++i)103printf"%d\n", Ans[i]);104 return 0; the}
View Code
BZOJ2120 Number of colors