Tag: causes body ref www. Print its = = array getc
Bzoj
We can find that the n,m,c are very small, so just open 100 two-dimensional bit to maintain it. Each color corresponds to a bit.
Then query the time with a two-dimensional prefix and to engage in it.
Started in the Bzoj time is T, and later found that the bit is too large, resulting in a slow addressing.
#include <bits/stdc++.h>Const intmax_n=300+5;intN,m,q;inta[max_n][max_n],bit[101][max_n][max_n];inline intRead () {Register intx=0;Register CharCh=getchar (); while(!isdigit (CH)) Ch=getchar (); while(IsDigit (CH)) {x= (x<<1) + (x<<3) +ch-' 0 '; Ch=getchar (); }returnx;}voidModifyintCintXintYintNUM) { for(intI=x;i<=n;i+=i&-i) for(intJ=Y;J<=M;J+=J&-J) Bit[c][i][j]+=num;}intQueryintCintXintY) {intres=0; for(intI=x;i;i-=i&-i) for(intJ=Y;J;J-=J&-J) Res+=bit[c][i][j];returnRes;}intMain () {intOpt,x,y,xt,yt,c; N=read (), M=read (); for(intI=1; i<=n;++i) { for(intj=1; j<=m;++j) {a[i][j]=read (); Modify (A[i][j],i,j,1); }} q=read (); while(q--) {Opt=read ();if(opt==1) {X=read (), Y=read (), C=read ();if(A[X][Y]==C)Continue; Modify (A[x][y],x,y,-1); A[x][y]=c; Modify (A[x][y],x,y,1); }Else{X=read (), Xt=read (), Y=read (), Yt=read (), C=read (); printf"%d\n", query (C,XT,YT)-query (c,xt,y-1)-query (c,x-1, YT) +query (c,x-1Y-1)); } }return 0;}
JSOI2009 Count [tree-shaped array]