链接

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

就是锤子可以移到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. 操作xml文档的常用方式

    1.操作XML文档的两种常用方式: 1)使用XmlReader类和XmlWriter类操作 XmlReader是基于数据流的,占用极少的内存,是只读方式的,所以速度极快.只能采用遍历的模式查找数据节点 ...

  2. 普通用户开启AUTOTRACE 功能

    AUTOTRACE是一个SQL*Plus工具,用于跟踪SQL的执行计划,收集执行时所耗用资源的统计信息.系统账户本身具有AUTOTRACE,其他账户需要通过手动赋予 一. 用系统账户登录(DBA) S ...

  3. 《C和指针》 读书笔记 -- 第9章 字符串、字符和字节

    1.字符串以NUL结尾,但字符串长度不包括NUl字节. 2.复制字符串 char *strcpy(char *dst,char const *src); 3.连接字符串 char *strcat(ch ...

  4. C语言控制语句总结(if else for switch while break continue)

    一.if语句 1表达式 if(条件表达式) 语句 注: (1)条件表达式,一般为逻辑表达式或关系表达式,但也可以是任何数值类型,如整型.实型.字符型.指针型数据等. (2)语句,由于是C语言的语句,而 ...

  5. WPF中禁止WebBrowser控件打开新窗口

    一.针对纯WPF的WebBrowser控件: <summary> Suppress Script Errors In WPF WebBrowser </summary> pub ...

  6. excle,aspose.cells 公式字段值取不到 xmls转xml

    问题: 一,单元格如果是公式的,读出值为0 aspose.cells 4.4.0.5版本 由于太低,读xmls后缀的excel文件时,发现如果此列是公式算出来的,值是获取不到的.获取到的值一直是0 二 ...

  7. Truncating HTML attribute value in SharePoint DataFormWebPart

    <xsl:value-ofdisable-output-escaping="yes"select="@Body"/>

  8. MySQL与Oracle主键Query性能测试结果

    测试结果总结如下: 1. 按主键读:SQL形式:SELECT * FROM table WHERE id=?. 1.1. 主键为数字.如果所有ID均不存在,纯比较SQL解析能力.MySQL解析SQL的 ...

  9. linux学习笔记(1)-文件处理相关命令

    列出文件和目录 ls (list) #ls 在终端里键入ls,并回车,就会列出当前目录的文件和目录,但是不包括隐藏文件和目录 #ls -a 列出当前目录的所有文件 #ls -al 列出当前目的所有文件 ...

  10. java程序练习:数组中随机10个数中的最大值

    //定义输入:其实是一个可以保存10个整数的数组 //使用循环遍历,生成10个随机数,放入每个元素中//打桩,数组中的内容 //定义输出变量 //将数组中第一个元素取出,保存在max中,当靶子 //遍 ...