连接:http://poj.org/problem?id=1054

题意:就是一个格子里一条线上最长有几个青蛙(青蛙间隔相同)~。但是其实青蛙的起点重点必须是在外面。

直接写一个搜就是。

 #include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#define loop(s,i,n) for(i = s;i < n;i++)
#define cl(a,b) memset(a,b,sizeof(a))
using namespace std;
int map[][];
int r,c,n;
struct node
{
int x,y;
}p[];
int cmp( struct node a, struct node b)
{
if(a.x == b.x)
return a.y < b.y;
return a.x < b.x;
}
int judge(int x,int y)
{
if(x >= && x <= r && y >= &&y <= c)
return ; return ; }
int find(struct node tmp,int dx,int dy)
{ int ans = ; int leap =;
while(judge(tmp.x+dx,tmp.y+dy))
{
if(map[tmp.x+dx][tmp.y+dy])
{
tmp.x+= dx,tmp.y += dy;
ans++;
}
else
{
leap = ;
break;
}
}
if(leap)
return ans;
return ;
}
int main()
{
while(~scanf("%d %d",&r,&c))
{
int i,j;
scanf("%d",&n); cl(map,);
for(i = ;i <= n;i++)
scanf("%d %d",&p[i].x,&p[i].y),map[p[i].x][p[i].y] = ; sort(p+,p+n+,cmp);
int ans = ;
for(i = ;i <= n;i++)
{ for(j = i+;j <= n;j++)
{ int dx,dy;
dx = p[j].x-p[i].x;
dy = p[j].y-p[i].y;
struct node tmp;
tmp = p[j];
if(judge(p[i].x-dx,p[i].y-dy))
continue;
int cnt = find(tmp,dx,dy); if(ans < cnt)
ans = cnt; }
}
if(ans < )
puts("");
else
printf("%d\n",ans);
}
return ;
}

poj1054 The Troublesome Frog 瞎搞。的更多相关文章

  1. POJ1054 The Troublesome Frog

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

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

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

  3. URAL 1203. Scientific Conference(瞎搞)

    题目链接 本来觉得这不是经典的贪心吗..果断水一次,wa了,看了看discuss,发现貌似不好水,土土的DP了一下,复杂度很高了,又T了...然后想想单调队列,二分什么的...不好往上加,直接搞了标记 ...

  4. POJ 1054 The Troublesome Frog

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

  5. Codeforces Gym 100610 Problem H. Horrible Truth 瞎搞

    Problem H. Horrible Truth Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1006 ...

  6. B. Salty Fish Go! -期望题(瞎搞题)

    链接:https://www.nowcoder.com/acm/contest/104/B来源:牛客网 题意:A few days ago, WRD was playing a small game ...

  7. HDU5532 Almost Sorted Array(最长上升子序列 or 瞎搞个做差的数组)

    题目链接:点我 题意:给定一个序列,询问是否能删除一个数让它成为非递减或者非递增的序列. 比如说 删除后的序列是1 3 3 5 或者5 3 3 1 或者1 3 5 或者5 3 1 都可以.只要满足删掉 ...

  8. TOJ3097: 单词后缀 (字典树 or map瞎搞)

    传送门 (<---可以点击的~) 时间限制(普通/Java):1000MS/3000MS     内存限制:65536KByte 描述 有些英语单词后缀都是一样的,现在我们需要从给定的一堆单词里 ...

  9. 8VC Venture Cup 2016 - Elimination Round B. Cards 瞎搞

    B. Cards 题目连接: http://www.codeforces.com/contest/626/problem/B Description Catherine has a deck of n ...

随机推荐

  1. Python自动发布Image service的实现

    使用Python自动发布地图服务已经在上一篇博客中讲到,使用Python创建.sd服务定义文件,实现脚本自动发布ArcGIS服务,下面是利用Python自动发布Image service的实现. -- ...

  2. 。。。。。。不带http https : 不报错 spring boot elasticsearch rest

    ......不带http https  : 不报错 先telnet http://onf:8080/getES653/道路桥梁正在“理疗”%20这14条道路纳入市政中修 @GetMapping(&qu ...

  3. Why Choose Jetty?

    https://webtide.com/why-choose-jetty/ Why Choose Jetty?   The leading open source app server availab ...

  4. linux: convmv =-======pkgs.org

    convmv 不同系统文件名转化 windows: gbk linux: utf8 wget--url coding. vim ---encoding,termcode, fileencoding, ...

  5. AOP切点表达式

    Aspectj切入点语法定义 在使用spring框架配置AOP的时候,不管是通过XML配置文件还是注解的方式都需要定义pointcut"切入点" 例如定义切入点表达式  execu ...

  6. JavaScript类库汇总

    日期处理Moment.js    http://momentjs.cn/  http://momentjs.com/ nodejslinq,jslinq    http://jslinq.codepl ...

  7. Java基础方法

    1:读取resource下面的文件 ClassPathResource cpr = new ClassPathResource("./MyBatisXmlFile"); File ...

  8. Mybatis的CRUD案例

    一.Mybatis增删改查案例 上一节<Mybatis入门和简单Demo>讲了如何Mybatis的由来,工作流程和一个简单的插入案例,本节主要继上一讲完整的展示Mybatis的CRUD操作 ...

  9. 给iphone配置qq邮箱

    在手机上使用qq邮箱发送和接受邮件,但是又不用qq邮箱,我用的是“网易邮箱大师” ,那么就需要配置服务. 1.在qq邮箱中设置邮箱,开启相关的服务,然后用手机发送短信来生成授权码.最后在手机上设置的密 ...

  10. Bootstrap table前端分页(ssm版)

    说明bootstrap table可以前端分页,也可以后端sql用limit分页.前端分页下性能和意义都不大,故一般情况下不用这种,请看我的另一篇后端分页的博客源码下载地址:https://git.o ...