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 ...
随机推荐
- windows 文件查找 大小:>250M
win7怎么快速查找大文件_百度经验 https://jingyan.baidu.com/article/acf728fd299ffff8e510a333.html
- gitlab-runner ---CI
gitlab-runner: https://segmentfault.com/a/1190000007180257 https://mp.weixin.qq.com/s?__biz=MjM5MTA1 ...
- postman app支持浏览器上的cookie
1. 安装postman app 注意要安装postman application(一个应用软件),而不是chrome 插件,打开下面的这个开关 2. chrom浏览器 给chrom浏览器安装pos ...
- mysql 数据操作 多表查询 多表连接查询 内连接
内连接:只连接匹配的行 只取两张表共同的部分,相当于利用where 过滤条件从笛卡尔积结果中筛选出了正确的结果 select * from 左表 inner join 要连接的表 on 条件 #dep ...
- python模块之signal信号
简介 作用:发送和接收异步系统信号 信号是一个操作系统特性,它提供了一个途径可以通知程序发生了一个事件并异步处理这个事件.信号可以由系统本身生成,也可以从一个进程发送到另一个进程. 由于信号会中断程序 ...
- PHP之设计模式
https://blog.csdn.net/self_realian/article/details/78228733 掌握PHP各类设计模式,具备设计纯面向对象框架和系统能力是非常有必要的.给大家一 ...
- 121. Best Time to Buy and Sell Stock(股票最大收益)
Say you have an array for which the ith element is the price of a given stock on day i. If you were ...
- springcloud21---Config-bus实现配置自动刷新
Pivotal(毕威拓)有VMware和EMC成立的. RabbitMQ是由ERlang(爱立信开发的,面向并发的编程语言),安装RabbitMQ先要安装ERlang. package com.itm ...
- Centos75 安装 postgresql11
切换到root账户, #安装yum 源 yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_6 ...
- Python3.x:sys.argv[]的简介
Python3.x:sys.argv[]的简介 sys模块通过sys.argv提供对任何命令行参数的访问.主要有两个参数变量: sys.argv是命令行参数的列表. len(sys.argv)是命令行 ...