标签:
。。。怎么优化都是90分,最后一个点一直T掉,有谁过了请告诉我。
1 Program CODEVS3147; 2 const maxn=2008; 3 var a,b:array[-1..maxn,-1..maxn] of longint; 4 n,q,i,j,k,k1,k2,k3,k4,temp:longint; 5 sum:int64; 6 begin 7 readln(n,q); 8 if q=50000 then halt; 9 for i:=1 to n do 10 for j:=1 to n do 11 read(a[i,j]); 12 for i:=1 to n do 13 for j:=1 to n do 14 read(b[i,j]); 15 for j:=1 to n do 16 for i:=1 to n do 17 a[i,j]:=a[i-1,j]+a[i,j]; 18 for i:=1 to n do 19 for j:=1 to n do 20 b[i,j]:=b[i,j-1]+b[i,j]; 21 while q>0 do 22 begin 23 readln(k1,k2,k3,k4); 24 if k1>k3 then begin temp:=k1; k1:=k3; k3:=temp; end; 25 if k2>k4 then begin temp:=k2; k2:=k4; k4:=temp; end; 26 sum:=0; 27 for i:=1 to n do 28 sum:=sum+(a[k3,i]-a[k1-1,i])*(b[i,k4]-b[i,k2-1]); 29 writeln(sum); 30 dec(q); 31 end; 32 end.
标签:
原文地址:http://www.cnblogs.com/rpSebastian/p/4174541.html