链接

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

就是锤子可以移到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. js 闭包 详解

    闭包(closure)是Javascript语言的一个难点,也是它的特色,很多高级应用都要依靠闭包实现. 闭包的特性 闭包有三个特性: 1.函数嵌套函数 2.函数内部可以引用外部的参数和变量 3.参数 ...

  2. linux 正则表达式深度解析

    正则表达式的文法分为3种标准:BRE.ERE 和 ARE.其中 BER 和 ERE 属于 POSIX 标准,ARE 则是由各家定义的扩展   简介 大体来讲,正则表达式的文法分为3种标准:BRE.ER ...

  3. ubuntu12.04 server + apache2 + wsgi + django1.6 部署

    最近在学Python和Django,想自己部署一个服务器试试 环境:ubuntu12.04 server | apache2 | django1.6 | python2.7 | mod_wsgi 在网 ...

  4. (转)Memcached

    Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提供动态.数据 库驱动网站的速度.Memcache ...

  5. Mooncake (排序+贪心)

    Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types ...

  6. 十五、mysql 分区之 分区管理

    1.mysql分区处理分区字段NULL值的方式 1.range分区null被当作最小值处理 2.list分区null值必须被枚举出来,否则将出错 3.hash/key分区 null值当作0处理 2.R ...

  7. ashx与验证码

    using System; using System.Drawing; using System.Drawing.Imaging; using System.Drawing.Drawing2D; us ...

  8. filter_map

    #!/usr/bin/env python # -*- coding:utf-8 -*- ret = filter( lambda x: x < 3, [1, 2, 3, 4, 5]) prin ...

  9. Nhibernate 多对多级联更新

    问题是这样的,有两个表:文章(Article)和分类(Lable),这两者之间的关系是多对多关联,如果你用Nhibernate来保存数据的话非常的好操作,新建Article,然后把Lable值赋值给A ...

  10. [转]SqlServer数据库同步方案详解

    SqlServer数据库同步是项目中常用到的环节,若一个项目中的数据同时存在于不同的数据库服务器中,而这些数据库需要被多个不同的网域调用时,配置 SqlServer数据库同步是个比较好的解决方案.Sq ...