Mo team template code

. 1  // Node saved interrogation interval, the order of
 2  // ARR array of numbers stored in the 1-n
 . 3  // CNT count array 
. 4  BOOL CMP (Node A, Node B) {
 . 5      IF (Al / BBLOCK! = BL / BBLOCK )
 . 6          return    Al / BBLOCK <BL / BBLOCK;
 . 7      return Ar < br;
 . 8  }
 . 9  
10  void Update () {
 . 11      int Val = ARR [POS];
 12 is      IF (n-== . 1 )
 13 is          ANS + = 2 * CNT [ Val] + . 1 ;
 14     else
15         ans-=2*cnt[val]+1;
16     cnt[val]+=n;
17 }
18 
19 void solve(){
20     for(int i=1;i<=m;i++){
21         while(L>node[i].l)
22             update(--L,1);
23         while(R<node[i].r)
24             update(++R,1);
25         while(L<node[i].l)
26             update(L++,-1);
27         while(R>node[i].r)
28             update(R--,-1);
29         res[node[i].id]=ans;
30     }
31 }

 

Guess you like

Origin www.cnblogs.com/gn1314/p/11444238.html