Topic links
Title Description
Description
The mole is a kind of animal that likes digging a hole very much, but every time, it still likes to poke his head out to the ground to breathe.
According to this feature, Ah Q wrote a game of hitting the mole: in a n*n grid, at some point the mole would try to breathe through a grid. You can control a robot to hit a mole, and 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 is to move from the current grid to the adjacent mesh, that is, from the coordinates (I,J) of the grid (I-1, J), (I+1, J), (I,j-1), (i,j+1) Four meshes, the robot cannot walk out of the entire n*n grid. At the beginning of the game, you are free to select the initial position of the robot.
Now you know the time and place where the mole appeared during a period of time, hoping you would write a program that would allow the robot to kill as many moles in this period of time.
Enter a description
Input Description
You will read the data from the file, the first act of the file N (n<=1000), M (m<=10000), where m represents the number of moles that appear in this period of time, and the next m row has three data per row time,x,y indicates that there is a mole at the beginning of the game time, A mole appeared in the grid of the first X row. Time is given in ascending order. Note that there may be many moles at the same time, but only one mole may appear at the same time in the same place.
Output description
Output Description
The output file contains only a positive integer that represents the maximum number of moles killed.
Sample input
Sample Input
2 2
1 1 1
2 2 2
Sample output
Sample Output
1
I feel my IQ is very low ... I didn't see it as LIS at all. Forced to think complex
#include <iostream>#include<vector>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<map>#include<Set>#include<string>#include<queue>#include<stack>#include<bitset>using namespacestd;#definePB (x) push_back (x)#definell Long Long#defineMK (x, y) make_pair (x, y)#defineLson L, M, rt<<1#defineMem (a) memset (a, 0, sizeof (a))#defineRson m+1, R, rt<<1|1#defineMem1 (a) memset (a,-1, sizeof (a))#defineMEM2 (a) memset (a, 0x3f, sizeof (a))#defineRep (i, N, a) for (int i = A; i<n; i++)#defineFi first#defineSe Secondtypedef pair<int,int>PLL;Const DoublePI = ACOs (-1.0);Const DoubleEPS = 1e-8;Const intMoD = 1e9+7;Const intINF =1061109567;Const intdir[][2] = { {-1,0}, {1,0}, {0, -1}, {0,1} };intdp[10005], Maxx;structnode{intx, y, t;} a[10005];intMain () {intN, M; CIN>>n>>m; for(inti =0; i<m; i++) {scanf ("%d%d%d", &a[i].t, &a[i].x, &a[i].y); } for(inti =0; i<m; i++) { for(intj = i+1; j<m; J + +) { if(ABS (a[j].x-a[i].x) +abs (A[J].Y-A[I].Y) <=a[j].t-a[i].t) {Dp[j]= Max (Dp[j], dp[i]+1); Maxx=Max (Maxx, Dp[j]); } }} cout<<maxx+1<<Endl; return 0;}
Codevs 1256 Dozen Mole LIS