ACM: 动态规划题 poj 3034
来源:互联网 发布:金山tw域名遭抢注 编辑:程序博客网 时间:2024/06/08 17:53
While visiting a travelingfun fair you suddenly have an urge to break the high score in theWhac-a-Mole game. The goal of the Whac-a-Mole game is to… well…whack moles. With a hammer. To make the job easier you have firstconsulted the fortune teller and now you know the exact appearancepatterns of the moles.
The moles appear out of holes occupying the n2integer points (x, y) satisfying 0 ≤ x,y < n in a two-dimensional coordinatesystem. At each time step, some moles will appear and thendisappear again before the next time step. After the moles appearbut before they disappear, you are able to move your hammer in astraight line to any position (x2,y2) that is at distance at most d from yourcurrent position (x1, y1). Forsimplicity, we assume that you can only move your hammer to a pointhaving integer coordinates. A mole is whacked if the center of thehole it appears out of is located on the line between(x1, y1) and(x2, y2) (including the twoendpoints). Every mole whacked earns you a point. When the gamestarts, before the first time step, you are able to place yourhammer anywhere you see fit.
Input
The input consists ofseveral test cases. Each test case starts with a line containingthree integers n, d and m, where n andd are as described above, and m is the total numberof moles that will appear (1 ≤ n ≤ 20, 1 ≤ d ≤ 5, and1 ≤ m ≤ 1000). Then follow m lines, each containingthree integers x, y and t giving the positionand time of the appearance of a mole (0 ≤ x, y< n and 1 ≤ t ≤ 10). No two moles willappear at the same place at the same time.
The input is ended with a test case where n = d =m = 0. This case should not be processed.
Output
For each test case output a single line containing a singleinteger, the maximum possible score achievable.
Sample Input
4 2 6
0 0 1
3 1 3
0 1 2
0 2 2
1 0 2
2 0 2
5 4 3
0 0 1
1 2 1
2 4 1
0 0 0
Sample Output
4
2
题意:
解题思路:
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define MAX 55
#define TIME 15
struct node
{
}p[MAX*2];
int n, d, m, N, T;
int g[TIME][MAX][MAX];
int dp[TIME][MAX][MAX];
int num;
inline int max(int a, int b)
{
}
bool cmp(node &a, node &b)
{
}
int gcd(int a, int b)
{
}
void init()
{
}
inline int getSum(int t, int x, int y, int xx , int yy, int dx,int dy)
{
}
int DP()
{
}
int main()
{
//
}
- ACM: 动态规划题 poj 3034
- ACM: 简单动态规划题 poj 2955
- ACM: 动态规划题 poj 2241
- ACM: 动态规划题 poj 1054
- ACM: 动态规划题 poj 2948
- ACM: 动态规划题 poj 1925
- ACM: 动态规划题 poj 2411
- ACM: 动态规划题 poj 1947
- ACM: 动态规划题 poj 2486
- ACM: 动态规划题 poj 3140
- ACM: 动态规划题 poj 3659
- ACM: 动态规划题 poj 2923
- ACM: dp动态规划题(难) poj 3267 …
- ACM: dp题(动态规划) poj 2151 (d…
- ACM: 树状DP 动态规划题 poj 1463 …
- ACM: 动态规划题 poj 2057 树状DP
- ACM:动态规划题 poj 1015
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj 1054
- ACM: 动态规划题 poj3280
- ACM: 树状数组 poj 2029 动态规划…
- ACM: 动态规划题 poj 2948
- ACM: 动态规划题 poj 1925
- ACM: 动态规划题 poj 3034
- ACM: 动态规划题 poj 3254 学习状…
- ACM: 动态规划题 poj 2411
- 埃拉托斯特尼筛法求素数
- 兴趣学习: 摆脱“三天打渔两天晒网”…
- ACM: 动态规划题 poj 1185 想了两…
- windows.h
- ACM: 动态规划题 poj 2057 树状DP
- ACM: 动态规划题 poj 1947