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 ...
随机推荐
- ELK服务基础
官方文档 什么是ELK? 通俗来讲,ELK是由Elasticsearch.Logstash.Kibana三个开源软件组成的一个组合体,这三个软件当中,每个软件用于完成不同的功能,ELK又称为ELK s ...
- D2 Magic Powder -1/- 2---cf#350D2(二分)
题目链接:http://codeforces.com/contest/670/problem/D2 This problem is given in two versions that differ ...
- kubernetes实战(三):k8s v1.11.1 持久化EFK安装
1.镜像下载 所有节点下载镜像 docker pull kibana: docker tag kibana: docker.elastic.co/kibana/kibana: docker pull ...
- 爬虫基础 - Robots协议
Robots协议 指定一个robots.txt文件,告诉爬虫引擎怎么爬取 https://www.taobao.com/robots.txt User-agent: Baiduspider Allow ...
- flask实现api
https://www.cnblogs.com/vovlie/p/4178077.html from flask import Flask, jsonify app = Flask(__name__) ...
- (转)SpringBoot非官方教程 | 第十二篇:springboot集成apidoc
首先声明下,apidoc是基于注释来生成文档的,它不基于任何框架,而且支持大多数编程语言,为了springboot系列的完整性,所以标了个题. 一.apidoc简介 apidoc通过在你代码的注释来生 ...
- fold change的意义[转载]
转自:https://zhidao.baidu.com/question/2052933434631672387.html 1.解释 解释:表达值倍数变化 ,分析,消除可能的混杂因素,必要时可以用读段 ...
- C#使用Gzip解压缩完整读取网页内容
using System; using System.Threading; using System.Text; using System.Text.RegularExpressions; using ...
- java中string.trim()函数的作用
trim /[trɪm] / 英文意思:整理,修理,修剪,整齐的 trim()的作用:去掉字符串首尾的空格. public static void main(String arg[]){ Strin ...
- cas php
CAS的php客户端实践—单点登录整合php程序 兄弟近日尝试将一个php程序以单点登录方式和原有的系统整合在一起.验证服务器选用的是CAS,其提供有相应的php客户端.整个过程如下:1.搭建CAS服 ...