Codeforces Gym 100002 C "Cricket Field" 暴力
"Cricket Field"
Time Limit: 1 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/gym/100002
Description
Once upon a time there was a greedy King who ordered his chief Architect to build a field for royal cricket inside his park. The King was so greedy, that he would not listen to his Architect's proposals to build a field right in the park center with pleasant patterns of trees specially planted around and beautiful walks inside tree alleys for spectators. Instead, he ordered neither to cut nor to plant even a single tree in his park, but demanded to build the largest possible cricket field for his pleasure. If the Kind finds that the Architect has dared to touch even a single tree in his park or designed a smaller field that it was possible, then the Architect will loose his head. Moreover, he demanded his Architect to introduce at once a plan of the field with its exact location and size.
Your task is to help poor Architect to save his head, by writing a program that will find the maximum possible size of the cricket field and its location inside the park to satisfy King's requirements.
The task is somewhat simplified by the fact, that King's park has a rectangular shape and is situated on a flat ground. Moreover, park's borders are perfectly aligned with North-South and East-West lines. At the same time, royal cricket is always played on a square field that is also aligned with North-South and East-West lines. Architect has already established a Cartesian coordinate system and has precisely measured the coordinates of every tree. This coordinate system is, of course, aligned with North-South and East-West lines. Southwestern corner of the park has coordinates (0, 0) and Northeastern corner of the part has coordinates (W, H), where W and H are the park width and height in feet respectively.
For this task, you may neglect the diameter of the trees. Trees cannot be inside the cricket field, but may be situated on its side. The cricket field may also touch park's border, but shall not lie outside the park.
Input
The first line of the input file contains three integer numbers N, W, and H, separated by spaces. N (0 ≤ N ≤ 100) is the number of trees in the park. W and H (1 ≤ W, H ≤ 10000) are the park width and height in feet respectively.
Next N lines describe coordinates of trees in the park. Each line contains two integer numbers Xi and Yi separated by a space (0 ≤ Xi ≤ W, 0 ≤ Yi ≤ H) that represent coordinates of ith tree. All trees are located at different coordinates.
Output
Write to the output file a single line with three integer numbers P, Q, and L separated by spaces, where (P, Q) are coordinates of the cricket field Southwestern corner, and L is a length of its sides. If there are multiple possible field locations with a maximum size, then output any one.
Sample Input
7 10 7
3 2
4 2
7 0
7 3
4 5
2 4
1 7
Sample Output
4 3 4
HINT
题意
给你个nm的区域,问你最大的内部没有树的正方形有多大(边界上可以有树
题解:
读入Y轴之后,暴力枚举Y轴
然后统计在这个区域的正方形最大是多少
代码:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <string>
#include <ctime>
#include <list>
#include <bitset>
typedef unsigned char byte;
#define pb push_back
#define input_fast std::ios::sync_with_stdio(false);std::cin.tie(0)
#define local freopen("in.txt","r",stdin)
#define pi acos(-1) using namespace std;
const int maxn = 1e2 + ;
int n , w , h ,ansx = , ansy = , ans = ;
struct point
{
int x , y ;
friend bool operator < (const point & a,const point & b)
{
return a.x < b.x || (a.x == b.x && a.y<b.y);
}
}; point p[maxn];
vector<int>Line; void initiation()
{
scanf("%d%d%d",&n,&w,&h);
Line.push_back();
Line.push_back(h);
for(int i = ; i < n ; ++ i)
{
scanf("%d%d",&p[i].x,&p[i].y);
Line.push_back(p[i].y);
}
} void solve()
{
sort(Line.begin() , Line.end());
int c = unique(Line.begin() , Line.end()) - Line.begin();
sort(p , p + n);
for(int i = ; i < c ; ++ i)
{
for(int j = i + ; j < c ; ++ j)
{
int L = Line[i];
int R = Line[j];
int h = R-L;
int pre = ;
for(int k = ; k < n ; ++ k)
{
if(p[k].y >= R || p[k].y <= L) continue;
int tx = p[k].x - pre;
int newans = min( tx , h );
if(newans > ans)
{
ans = newans;
ansx = pre;
ansy = L;
}
pre = p[k].x;
}
int tx = w - pre;
int newans = min( tx , h );
if(newans > ans)
{
ans = newans;
ansx = pre;
ansy = L;
}
}
}
printf("%d %d %d\n",ansx,ansy,ans);
} int main(int argc,char *argv[])
{
freopen("cricket.in","r",stdin);
freopen("cricket.out","w",stdout);
initiation();
if(n == ) printf("0 0 %d\n",min(w,h));
else solve();
return ;
}
Codeforces Gym 100002 C "Cricket Field" 暴力的更多相关文章
- Codeforces Gym 100002 E "Evacuation Plan" 费用流
"Evacuation Plan" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...
- Codeforces Gym 100002 Problem F "Folding" 区间DP
Problem F "Folding" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/ ...
- Codeforces Gym 100002 D"Decoding Task" 数学
Problem D"Decoding Task" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com ...
- Codeforces Gym 100002 B Bricks 枚举角度
Problem B Bricks" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100002 ...
- Codeforces Gym 100513M M. Variable Shadowing 暴力
M. Variable Shadowing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/ ...
- Codeforces Gym 100513G G. FacePalm Accounting 暴力
G. FacePalm Accounting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513 ...
- Codeforces Gym 100342E Problem E. Minima 暴力
Problem E. MinimaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attac ...
- Codeforces Gym 100203G G - Good elements 暴力
G - Good elementsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...
- Codeforces Gym 101190M Mole Tunnels - 费用流
题目传送门 传送门 题目大意 $m$只鼹鼠有$n$个巢穴,$n - 1$条长度为$1$的通道将它们连通且第$i(i > 1)$个巢穴与第$\left\lfloor \frac{i}{2}\rig ...
随机推荐
- css中position:relative的真正理解
其实话说一直以来也没真正去理解好position:relative的用法的真实意义. 我想很多人实实在在用的多都是position:relative和position:absolute结合起来一起用的 ...
- java transient简介
我们都知道一个对象只要实现了Serilizable接口,这个对象就可以被序列化,java的这种序列化模式为开发者提供了很多便利,我们可以不必关系具体序列化的过程,只要这个类实现了Serilizable ...
- Hadoop集群中Hbase的介绍、安装、使用
导读 HBase – Hadoop Database,是一个高可靠性.高性能.面向列.可伸缩的分布式存储系统,利用HBase技术可在廉价PC Server上搭建起大规模结构化存储集群. 一.Hbase ...
- [Papers]NSE, $u_3$, Lebesgue space [Zhou-Pokorny, Nonlinearity, 2009]
$$\bex u_3\in L^p(0,T;L^q(\bbR^3)),\quad \frac{2}{p}+\frac{3}{q}=\frac{3}{4}+\frac{1}{2q},\quad \fra ...
- 1047图的深度优先遍历c语言
描述 图(graph)是数据结构 G=(V,E),其中V是G中结点的有限非空集合,结点的偶对称为边(edge):E是G中边的有限集合.设V={0,1,2,……,n-1},图中的结点又称为顶点(vert ...
- android 滑动菜单SlidingMenu的实现
首先我们看下面视图: 这种效果大家都不陌生,网上好多都说是仿人人网的,估计人家牛逼出来的早吧,我也参考了一一些例子,实现起来有三种方法,我下面简单介绍下: 方法一:其实就是对Gesture ...
- Android Dialog用法
摘要: 创建对话框 一个对话框一般是一个出现在当前Activity之上的一个小窗口. 处于下面的Activity失去焦点, 对话框接受所有的用户交互. 对话框一般用于提示信息和与当前应用程序直接相关的 ...
- (原创)LAMP教程6-使用SecureCRTPortable工具远程连接centos
(原创)LAMP教程6-使用SecureCRTPortable工具远程连接centos 是的,今天老柯就给大家介绍一款可以远程连接centos的工具,是的这个就是目前,最夯实的,最多人使用的Secur ...
- 细雨学习笔记:Jmeter参数化
目前我用到两种方式: 1)某个参数,值不常改变的,好多地方都用到:请用“用户定义的变量” 用户组,右键--添加--配置原件--用户定义的变量,在这添加. 如何使用呢?在需要用到此参数的地方这样引用: ...
- LeetCode题解——Integer to Roman
题目: 将整数转换为罗马数字.罗马数字规则可以参考: 维基百科-罗马数字 解法: 类似于进制转换,从大的基数开始,求整数对基数的商和余,来进行转换. 代码: class Solution { publ ...