链接

想O(n*n)的DP  怎么想都超内存 看讨论有说hash+DP过的 实现比较繁琐

大部分直接暴力过了

直接枚举每个i j 与他们在一条线上的点 是不是给出的点

注意它必须能跳进和跳出

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
using namespace std;
#define N 5010
bool flag[N][N];
struct node
{
int x,y;
}p[N];
bool cmp(node a,node b)
{
if(a.x==b.x)
return a.y<b.y;
return a.x<b.x;
}
int main()
{
int i,j,k,n,r,c;
while(scanf("%d%d",&r,&c)!=EOF)
{
memset(flag,,sizeof(flag));
scanf("%d",&n);
for(i = ; i <= n ;i++)
{
scanf("%d%d",&p[i].x,&p[i].y);
flag[p[i].x][p[i].y] = ;
}
sort(p+,p+n+,cmp);
int ans=,ff=;
for(i = ; i <= n ; i++)
for(j = i+; j <= n ; j++)
{
int tx = p[j].x-p[i].x;
int ty = p[j].y - p[i].y;
int ox = p[j].x;
int oy = p[j].y;
if(p[i].x-tx>=&&p[i].x-tx<=r&&p[i].y-ty>=&&p[i].y-ty<=c)
continue;
ff = ;
for(k = ; ; k++)
{
ox+=tx;
oy+=ty;
if(ox>r||oy>c||ox<||oy<)
break;
if(!flag[ox][oy])
{
ff = ;
break;
}
}
if(ff)
ans = max(ans,k);
}
if(ans>)
printf("%d\n",ans);
else
printf("0\n");
}
return ;
}

poj1054The Troublesome Frog的更多相关文章

  1. POJ 1054 The Troublesome Frog

    The Troublesome Frog Time Limit: 5000MS Memory Limit: 100000K Total Submissions: 9581 Accepted: 2883 ...

  2. POJ1054 The Troublesome Frog

    题目来源:http://poj.org/problem?id=1054 题目大意: 有一种青蛙在晚上经过一片稻田,在庄稼上跳跃,会把庄稼压弯.这让农民很苦恼.我们希望通过分析青蛙跳跃的路径,找出对稻田 ...

  3. (中等) POJ 1054 The Troublesome Frog,记忆化搜索。

    Description In Korea, the naughtiness of the cheonggaeguri, a small frog, is legendary. This is a we ...

  4. IOI2002 POJ1054 The Troublesome Frog 讨厌的青蛙 (离散化+剪枝)

    Description In Korea, the naughtiness of the cheonggaeguri, a small frog, is legendary. This is a we ...

  5. The Troublesome Frog

    In Korea, the naughtiness of the cheonggaeguri, a small frog, is legendary. This is a well-deserved ...

  6. POJ 1054 The Troublesome Frog(枚举+剪枝)

    题目链接 题意 :给你r*c的一块稻田,每个点都种有水稻,青蛙们晚上会从水稻地里穿过并踩倒,确保青蛙的每次跳跃的长度相同,且路线是直线,给出n个青蛙的脚印点问存在大于等于3的最大青蛙走的连续的脚印个数 ...

  7. poj 1054 The Troublesome Frog (暴力搜索 + 剪枝优化)

    题目链接 看到分类里是dp,结果想了半天,也没想出来,搜了一下题解,全是暴力! 不过剪枝很重要,下面我的代码 266ms. 题意: 在一个矩阵方格里面,青蛙在里面跳,但是青蛙每一步都是等长的跳, 从一 ...

  8. Poj 1054 The Troublesome Frog / OpenJudge 2812 恼人的青蛙

    1.链接地址: http://poj.org/problem?id=1054 http://bailian.openjudge.cn/practice/2812 2.题目: 总时间限制: 10000m ...

  9. 【POJ】1054 The Troublesome Frog

    题目是非常经典的搜索+剪枝.题意简言之就是,青蛙需要沿着直线踩着踏点通过田地,并且踏点需要至少为3.问哪条路径青蛙踩坏的作物最多.很好的一个条件是青蛙每次移动都是等间距的.题目需要注意将其排序. #i ...

随机推荐

  1. ios 经典错误

    1 - [person test]:unrecognized selector sent to instance. 给penson对象发送一个不能识别的消息:test   2 set/get方法死循环 ...

  2. C# .NET 获取枚举值的自定义属性(特性/注释/备注)信息

    一.引言 枚举为我看日常开发的可读性提供的非常好的支持,但是有时我们需要得到枚举值得描述信息或者是注释(备注)信息 比如要获得 TestEmun.aaa 属性值得备注 AAA,比较不方便得到. pub ...

  3. 【html】【16】高级篇--毛玻璃效果[模糊]

    参考: http://www.zhangxinxu.com/wordpress/2013/11/%E5%B0%8Ftip-%E4%BD%BF%E7%94%A8css%E5%B0%86%E5%9B%BE ...

  4. JavaScript基础-对象<2>

    2.浏览器环境提供对象 (1) document对象 doucument对象属性: title:文本标题.doucument.title="Welcome"; lastModifi ...

  5. javascript 正则 验证 第25节

    <html> <head> <title>Form对象</title> <script type="text/javascript&qu ...

  6. 如何在浏览器网页中实现java小应用程序的功能

    我们知道,java语言的运用就是面向对象实现功能,和c不同,java语言对于程序员来说,运用起来更为简便. 小应用程序与应用程序不同,小应用程序只能在与Java兼容的容器中运行,可以嵌入在HTML网页 ...

  7. 一种c#深拷贝方式完胜java深拷贝(实现上的对比)

    楼主是一名asp.net攻城狮,最近经常跑java组客串帮忙开发,所以最近对java的一些基础知识特别上心.却遇到需要将一个对象深拷贝出来做其他事情,而原对象保持原有状态的情况.(实在是不想自己new ...

  8. jquery的effect-color对easyui没效果.自己冒险写个边框的颜色闪烁.

    "jquery-ui-effect-color.js" 是从jqueryui下载的color动画部分(自己改了个名字). 链接 <!DOCTYPE html> < ...

  9. C语言的奇技

    1.一个整型变量/字面值常量通常足够大,可以同时表示几个字符,所以有的C编译器允许字符常量/char及整型常量有多个字符.这表明当用' yes' 替代" yes" 时可能不会被发现 ...

  10. 用VIM写作

    Write in VIm 1.Writing in Vim by Dr. Bunsen