链接

状态转移好想 不过有坑 大家都犯的错误 我也会犯 很正常

就是锤子可以移到n*n以外  要命的是我只加了5 以为最多不会超过5  WA了N久  才想到 上下两方向都可以到5 所以最多加10

以时间和坐标进行DP

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<cmath>
using namespace std;
#define N 1010
#define M 32
struct node
{
int x[N],y[N];
}f[M][M];
int o[][M][M];
int dp[][M][M];
int n,nu[M][M];
int dis(int x1,int y1,int x2,int y2)
{
if(x1<||x1>=n+||y1<||y1>=n+)
return -;
int s;
s = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
return s;
}
int main()
{
int i,j,g,k,d,kk,m;
while(scanf("%d%d%d",&n,&d,&m)!=EOF)
{
if(n==&&d==&&m==)
break;
memset(dp,,sizeof(dp));
memset(o,,sizeof(o));
memset(nu,,sizeof(nu));
int maxz = ;
int a,b,c;
for(i = ; i <= m ; i++)
{
scanf("%d%d%d",&a,&b,&c);
o[c][a+][b+] =;
maxz = max(maxz,c);
}
int ans=;
for(i = ; i < n+ ; i++)
for(j = ;j < n+ ; j++)
{
int po = ;
for(k = -d; k <= d; k++)
for(kk = -d; kk <= d ; kk++)
{
int tx = i+k;
int ty = j+kk;
if(dis(tx,ty,i,j)!=-&&dis(tx,ty,i,j)<=d*d)
{
po++;
f[i][j].x[po] = tx;
f[i][j].y[po] = ty;
nu[i][j] = po;
}
}
}
for(i = ;i <= maxz ; i++)
for(j = ; j < n+ ; j++)
for(g = ; g < n+ ; g++)
for(k = ; k <= nu[j][g] ; k++)
{
int tx = f[j][g].x[k];
int ty = f[j][g].y[k];
int x1 = min(tx,j),x2 = max(tx,j);
int y1 = min(ty,g),y2 = max(ty,g);
int num = ;
for(kk = x1; kk <= x2 ; kk++)
for(int mm = y1 ; mm <= y2 ; mm++)
{
if((ty-g)*(kk-j)==(tx-j)*(mm-g)&&o[i][kk][mm])
num++;
}
dp[i][tx][ty] = max(dp[i][tx][ty],dp[i-][j][g]+num);
ans = max(ans,dp[i][tx][ty]);
}
printf("%d\n",ans);
}
return ;
}

poj3034Whac-a-Mole(dp)的更多相关文章

  1. BZOJ4849[Neerc2016]Mole Tunnels——模拟费用流+树形DP

    题目描述 鼹鼠们在底下开凿了n个洞,由n-1条隧道连接,对于任意的i>1,第i个洞都会和第i/2(取下整)个洞间有一条隧 道,第i个洞内还有ci个食物能供最多ci只鼹鼠吃.一共有m只鼹鼠,第i只 ...

  2. (中等) POJ 3034 Whac-a-Mole,DP。

    Description While visiting a traveling fun fair you suddenly have an urge to break the high score in ...

  3. Codeforces Round #271 (Div. 2) D 简单dp

    D. Flowers time limit per test 1.5 seconds memory limit per test 256 megabytes input standard input ...

  4. Mole and Abandoned Mine

    Mole and Abandoned Mine n点m条边的无向图,删除第i条边花费c[i],问1到n只有一条路径时所需要的最小花费? \(2\le n\le 15\) . 我又A掉了一道zzs的题啦 ...

  5. Codeforces Round #271 (Div. 2) D Flowers【计数dp】

    D. Flowers time limit per test 1.5 seconds memory limit per test 256 megabytes input standard input ...

  6. BZOJ 1207 [HNOI2004]打鼹鼠:dp【类似最长上升子序列】

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1207 题意: 有一个n*n的网格,接下来一段时间内会有m只鼹鼠出现. 第i只鼹鼠会在tim ...

  7. Codeforces Round #271 (Div. 2) D.Flowers DP

    D. Flowers   We saw the little game Marmot made for Mole's lunch. Now it's Marmot's dinner time and, ...

  8. Codeforces 474D Flowers (线性dp 找规律)

    D. Flowers time limit per test:1.5 seconds memory limit per test:256 megabytes We saw the little gam ...

  9. BZOJ 1911: [Apio2010]特别行动队 [斜率优化DP]

    1911: [Apio2010]特别行动队 Time Limit: 4 Sec  Memory Limit: 64 MBSubmit: 4142  Solved: 1964[Submit][Statu ...

  10. 2013 Asia Changsha Regional Contest---Josephina and RPG(DP)

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4800 Problem Description A role-playing game (RPG and ...

随机推荐

  1. YII千万级PV架构经验分享--俯瞰篇--性能介绍

    一张图,啥也不说了.直接上图,大图真难画. 呃,非得写满二百个字,其实本来想画均衡负债,一些服务器假设列子的,突然发现,没有业务要求,画不出来.写了这么久了,天天熬夜,得休息几天再继续.其实还有非常重 ...

  2. 在linux下配置Nginx+Java+PHP的环境

    Apache对Java的支持很灵活,它们的结合度也很高,例如Apache+Tomcat和Apache+resin等都可以实现对Java应用 的支持.Apache一般采用一个内置模块来和Java应用服务 ...

  3. 虚拟机安装Centos6.5之后的网络配置

    我使用的是minimal模式安装的,默认是无法联网的,需要自己配置,下面我列举2种联网的配置方法 方法1: 默认使用的是NAT模式,修改/etc/sysconfig/network-scripts/i ...

  4. MS也遵守规范了

    CSS学的好不好,就看你对浏览器的兼容性处理的好不好. 拿opacity来说,本来写成opacity:0.3就完事了,但MS不来这套,它用filter,我们就不得不专门为它而 加上这么一大串(file ...

  5. cadence 焊盘制作小结

    因为以前一直用altium designer 话PCB,做封装的时候焊盘是不用自己操心的,但是开始用cadence以后发现好多以前不太懂的东西,需要自己画焊盘,这就导致需要了解好多自己以前不懂的东西, ...

  6. ios Base64编解码工具类及使用

    为了避免明码传递http内容,可以用base64编码后传输,收到方再解码,也方便了2进制数据的字符串式传输. 对于ios来说,google给提供了一个很好的工具类,方便进行base64编解码,当然也可 ...

  7. UML include、generalization、extend、association

    1.别人的说法 转自:http://www.cnblogs.com/shinings/archive/2009/04/21/1440765.html 共性:都是从现有的用例中抽取出公共的那部分信息,作 ...

  8. iisapp appcmd

    C:\Windows\System32\inetsrv>appcmd list wp

  9. json tree

    // 确定取消 ' return div; }, setCss: function () { var s = this.el.style; s.position = 'absolute'; s.top ...

  10. C++内存泄露调试

    我在看DirectX Sample的时候,看到以下代码: // Enable run-time memory check for debug builds. #if defined(DEBUG) | ...