CodeForces 617C【序枚举】
题意:
有两个点喷水,有很多个点有花,给出坐标。
求使得每个花都可以被喷到,两个喷水的半径的平方的和最小是多少。
思路:
枚举其中一个喷水的最大半径。
坑:
这题我贪心的思路有很大问题。一开始也是想这样枚举的,但是思路超级混乱,按照r2进行贪心但是最后想想想法很荒谬。
顺序和题意一定要搞的很透彻才可以==
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct st
{
long long x,y,dis1,dis2;
};
bool cmp(st a,st b)
{
return a.dis1>b.dis1;
}
st point[];
st fla1,fla2;
long long cal(st a,st b)
{
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
int main()
{
int n;
scanf("%d",&n);
long long r1=,r2=;
scanf("%I64d%I64d%I64d%I64d",&fla1.x,&fla1.y,&fla2.x,&fla2.y);
for(int i=;i<n;i++)
{
scanf("%I64d%I64d",&point[i].x,&point[i].y);
point[i].dis1=cal(point[i],fla1);
point[i].dis2=cal(point[i],fla2);
}
sort(point,point+n,cmp);
long long ans=point[].dis1;
r2=;
for(int i=;i<n;i++)
{
ans=min(ans,point[i].dis1+r2);
r2=max(r2,point[i].dis2);
}
ans=min(ans,r2);
printf("%I64d\n",ans);
}
CodeForces 617C【序枚举】的更多相关文章
- Codeforces 165E Compatible Numbers(二进制+逆序枚举)
E. Compatible Numbers time limit per test 4 seconds memory limit per test 256 megabytes input standa ...
- codeforces 1183F 离散化枚举 约数定理
codeforces1183F 有技巧的暴力 传送门:https://codeforces.com/contest/1183/problem/F 题意: 给你n个数,要你从中选出最多三个数,使得三个数 ...
- CodeForces 617C Watering Flowers
无脑暴力题,算出所有点到圆心p1的距离的平方,从小到大排序. 然后暴力枚举p1的半径的平方,计算剩余点中到p2的最大距离的平方,枚举过程中记录答案 #include<cstdio> #in ...
- CodeForces 156B Suspects(枚举)
B. Suspects time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...
- 2018ICPC徐州区域赛网络赛B(逆序枚举或者正序深度搜索)
#include<bits/stdc++.h>using namespace std;int n,m,k,l;int x[1007],y[1007],z[1007];int dp[1007 ...
- CodeForces 379D 暴力 枚举
D. New Year Letter time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- CodeForces 280B(枚举 + 单调栈应用)
题目链接 思路如下 这题恶心的枚举任意区间的 最大值及次最大值 ,正常的操作是,是很难实现的,但偏偏有个 单调栈这个动西,能够完成这个任务,跟单调队列相似,有单调 递增.递减的栈,这一题我们需要维护的 ...
- Codeforces 1154G(枚举)
我预处理\(1e7log(1e7)\)的因数被T掉了,就不敢往这个复杂度想了--无奈去看AC代码 结果怎么暴举gcd剪一剪小枝就接近3s卡过去了!vector有锅(确信 const int maxn ...
- Codeforces Round #380 (Div. 1, Rated, Based on Technocup 2017 - Elimination Round 2)
http://codeforces.com/contest/737 A: 题目大意: 有n辆车,每辆车有一个价钱ci和油箱容量vi.在x轴上,起点为0,终点为s,中途有k个加油站,坐标分别是pi,到每 ...
随机推荐
- MySQL和MongoDB语句的写法对照
查询: MySQL: SELECT * FROM user Mongo: db.user.find() MySQL: SELECT * FROM user WHERE name = ’starlee’ ...
- replace() replace_copy()
int a[] = {1,2,3,3,4}; vector<int> v(a, a+5); vector<int> v2; //replace(v.begin(), v.end ...
- 如何在Dynamics CRM 2011 的窗体表单上加载报表
1.代码 function onloadReport() { if (crmForm.FormType != 1 && crmForm.FormType != 5) { $(" ...
- ASP.NET MVC 页面调整并传递参数
转自:http://blog.csdn.net/zhensoft163/article/details/7174661 使用过ASP.NET MVC的人都知道在MVC中页面后台中常用的页面跳转方法有几 ...
- Oracle 11g R2 常用配置与日志的文件位置
假设.bash_profile中oracle相关环境变量如下: $ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 $ORACLE_BASE=/u01/a ...
- 用Bouncy Castle的C#版API产生公钥和私钥
开源API链接地址:The Legion of the Bouncy Castle Bouncy Castle,简称为BC,原本是java的一个开源JCE提供者,后来也提供了C#版本的API,我下载其 ...
- 【jmeter】JMeter处理Cookie与Session
有些网站保存信息是使用Cookie,有些则是使用Session.对于这两种方式,JMeter都给予一定的支持. 1.Cookie 添加方式:线程组-配置元件-HTTP Cookie 管理器,如下图: ...
- get utc+8 当时时间
/// <summary> /// get utc+8 当时时间 /// </summary> /// <returns></returns> publ ...
- ajaxForm笔记
<script src="Scripts/jquery.form.js" type="text/javascript"></script> ...
- QT显示中文的几个问题
最近用QT,需要在界面上显示中文,发现QT无法直接在代码中写中文,只能通过曲线救国的方式,比如用QT语言家,QTextCodec的fromloca8bit 研究了半天,终于明白了一些编码的问题 1.V ...