BZOJ1218[HNOI2003] Laser bombs
Test instructions
There are n targets in the coordinate system, each of which has a value, and now a square with an edge that is an R, which is the maximum value of the target in its interior (the original question does not include the boundary, but in fact it is not).
Exercises
Preprocess the two-dimensional prefix of the node with a horizontal ordinate, and then enumerate the coordinates of the upper right corner of the square. Note You can move the coordinate system up one unit to the right and leave the prefixes and negative numbers in mind. Reflection: Konjac konjac Good weak ah, the enumeration of I and J boundary should be the maximum value of the node horizontal axis maximum and ordinate maximum value. Konjac Konjac did not notice this at first, thinking that he was pre-written wrong. Change to change, WA to WA to go. Finally, a little change in the calibration process to find the problem. Qaq
Code:
1#include <cstdio>2#include <cstring>3#include <algorithm>4 #defineMAXN 55005 #defineInc (I,J,K) for (int i=j;i<=k;i++)6 using namespacestd;7 8 intsum[maxn][maxn],n,mxxy,r,mx;9 intMain () {Tenscanf"%d%d", &n,&r); mxxy=mx=0; OneInc (I,1, N) { A intX, Y, Z scanf"%d%d%d", &x,&y,&z); x + +; y++; -Mxxy=max (MXXY,X); Mxxy=max (Mxxy,y); sum[x][y]+=Z; - } theInc (I,1, Mxxy) Inc (J,1, Mxxy) -sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]; - Inc (I,R,MXXY) Inc (J,R,MXXY) -Mx=max (mx,sum[i][j]-sum[i][j-r]-sum[i-r][j]+sum[i-r][j-R]); +printf"%d", MX);return 0; -}
20160602
BZOJ1218[HNOI2003] Laser bombs