poj1054 The Troublesome Frog 瞎搞。
连接: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 瞎搞。的更多相关文章
- POJ1054 The Troublesome Frog
题目来源:http://poj.org/problem?id=1054 题目大意: 有一种青蛙在晚上经过一片稻田,在庄稼上跳跃,会把庄稼压弯.这让农民很苦恼.我们希望通过分析青蛙跳跃的路径,找出对稻田 ...
- IOI2002 POJ1054 The Troublesome Frog 讨厌的青蛙 (离散化+剪枝)
Description In Korea, the naughtiness of the cheonggaeguri, a small frog, is legendary. This is a we ...
- URAL 1203. Scientific Conference(瞎搞)
题目链接 本来觉得这不是经典的贪心吗..果断水一次,wa了,看了看discuss,发现貌似不好水,土土的DP了一下,复杂度很高了,又T了...然后想想单调队列,二分什么的...不好往上加,直接搞了标记 ...
- POJ 1054 The Troublesome Frog
The Troublesome Frog Time Limit: 5000MS Memory Limit: 100000K Total Submissions: 9581 Accepted: 2883 ...
- Codeforces Gym 100610 Problem H. Horrible Truth 瞎搞
Problem H. Horrible Truth Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1006 ...
- B. Salty Fish Go! -期望题(瞎搞题)
链接:https://www.nowcoder.com/acm/contest/104/B来源:牛客网 题意:A few days ago, WRD was playing a small game ...
- HDU5532 Almost Sorted Array(最长上升子序列 or 瞎搞个做差的数组)
题目链接:点我 题意:给定一个序列,询问是否能删除一个数让它成为非递减或者非递增的序列. 比如说 删除后的序列是1 3 3 5 或者5 3 3 1 或者1 3 5 或者5 3 1 都可以.只要满足删掉 ...
- TOJ3097: 单词后缀 (字典树 or map瞎搞)
传送门 (<---可以点击的~) 时间限制(普通/Java):1000MS/3000MS 内存限制:65536KByte 描述 有些英语单词后缀都是一样的,现在我们需要从给定的一堆单词里 ...
- 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 ...
随机推荐
- CRM - 起步
一.crm简介 crm 客户关系管理软件 ( Customer Relationship Management ) 二.起步 models.py 表结构 from django.db import m ...
- kubernetes实战(三):k8s v1.11.1 持久化EFK安装
1.镜像下载 所有节点下载镜像 docker pull kibana: docker tag kibana: docker.elastic.co/kibana/kibana: docker pull ...
- java 多线程 day17 Exchanger
import java.util.concurrent.Exchanger;import java.util.concurrent.ExecutorService;import java.util.c ...
- UVA大模拟代码(白书训练计划1)UVA 401,10010,10361,537,409,10878,10815,644,10115,424,10106,465,10494
白书一:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=64609#overview 注意UVA没有PE之类的,如果PE了显示WA. UVA ...
- PAT 1138 Postorder Traversal [比较]
1138 Postorder Traversal (25 分) Suppose that all the keys in a binary tree are distinct positive int ...
- 学习Mysql的记录贴 记录的内容是 指令的试用
前言:操作系统是WIn7 64位 旗舰版 ,Mysql的版本是mysql-5.7.10-winx64 是社区版 就是所谓的最后的免费版本. 下载后 解压 然后配置my.ini文件. ××××××× ...
- Console 窗口
Console窗口 记住,即是在GUI程序中你也可以拥有一个Console窗口.----这意味着你可以再GUI程序中使用printf.puts. Console窗口由系统的驱动设备程序负责,即是你的程 ...
- SpringBoot 通过自定义注解实现AOP切面编程实例
一直心心念的想写一篇关于AOP切面实例的博文,拖更了许久之后,今天终于着手下笔将其完成. 基础概念 1.切面(Aspect) 首先要理解‘切’字,需要把对象想象成一个立方体,传统的面向对象变成思维,类 ...
- C Strange Sorting
C. Strange Sorting time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Java面试:投行的15个多线程和并发面试题
多线程和并发问题已成为各种 Java 面试中必不可少的一部分.如果你准备参加投行的 Java 开发岗位面试,比如巴克莱银行(Barclays).花旗银行(Citibank).摩根史坦利投资公司(Mor ...