1 program hehe; 2 var 3 n,m,i,j,q,x1,y1,x2,y2,co:longint; 4 y:array[0..300,0..300] of longint; 5 x:array[0..100,0..300,0..300] of longint; 6 7 procedure add(k,a,b,t:longint); 8 var 9 c:longint;10 begin11 while a<=n do12 begin13 c:=b;14 while c<=m do15 begin16 x[k,a,c]:=x[k,a,c]+t;17 c:=c+(c and(-c));18 end;19 a:=a+(a and(-a));20 end;21 end;22 23 function find(k,a,b:longint):longint;24 var25 s,c:longint;26 begin27 s:=0;28 while a>0 do29 begin30 c:=b;31 while c>0 do32 begin33 s:=s+x[k,a,c];34 c:=c-(c and(-c));35 end;36 a:=a-(a and(-a));37 end;38 exit(s);39 end;40 41 begin42 readln(n,m);43 for i:=1 to n do44 for j:=1 to m do45 begin46 read(y[i,j]);47 add(y[i,j],i,j,1);48 end;49 readln(q);50 for i:=1 to q do51 begin52 read(j);53 if j=1 then54 begin55 readln(x1,y1,co);56 add(y[x1,y1],x1,y1,-1);57 y[x1,y1]:=co;58 add(co,x1,y1,1);59 end60 else61 begin62 readln(x1,x2,y1,y2,co);63 writeln(find(co,x2,y2)-find(co,x1-1,y2)-find(co,x2,y1-1)+find(co,x1-1,y1-1));64 end;65 end;66 end.
1452: [JSOI2009]Count
Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 1414 Solved: 831[][][]Description
Input
Output
Sample Input
Sample Output
1 2