BZOJ1207[HNOI2004] hit the mole
Test instructions
In a n*n grid, if I moment the mole appears in a grid and the robot is in the same grid, the mole will be killed by the robot. And the robot can only move one cell at a time or stay where it is. The movement of a robot means moving from the current grid to the adjacent grid, and not out of the entire n*n grid. At the beginning of the game, you are free to select the initial position of the robot. For a period of time, the mole appeared at the time and place, asking the robot to kill as many moles as possible during this time period.
Exercises
A problem similar to the longest common substring enumerated, which was reached after hitting a hamster before hitting a hamster, because the data is weak to use without adding strange optimizations.
Code:
1#include <cstdio>2#include <cstring>3#include <algorithm>4 #defineInc (I,J,K) for (int i=j;i<=k;i++)5 using namespacestd;6 intf[20000],t[20000],x[20000],y[20000];7 intMain () {8 intN,m; scanf"%d%d", &n,&m);intans=0;9Inc (I,1, M) {Tenscanf"%d%d%d", &t[i],&x[i],&y[i]);intmx=0; OneInc (J,1, I-1)if(T[i]-t[j]>=abs (X[i]-x[j]) +abs (Y[i]-y[j]) mx=Max (mx,f[j]); Af[i]=mx+1; ans=Max (ans,f[i]); - } -printf"%d", ans); the return 0; -}
20160324
BZOJ1207[HNOI2004] hit the mole