Codeforces Round #549 (Div. 2) F 数形结合 + 凸包(新坑)
https://codeforces.com/contest/1143/problem/F
题意
有n条形如\(y=x^2+bx+c\)的抛物线,问有多少条抛物线上方没有其他抛物线的交点
题解
- \(y=x^2+bx+c=>y+x^2=bx+c\),转换为点\((x,y+x^2)\)在bx+c的直线上
- 两个点确定一条抛物线,同时也确定了一条直线
- 需要选择最上面那些点相邻确定的抛物线,所以维护一个上凸包即可
- 维护上凸包,当前点在前进方向左边需要向后退,cross(a,b)>=0
代码
#include<bits/stdc++.h>
#define MAXN 100005
#define ll long long
using namespace std;
const double eps=1e-8;
struct N{
long long x,y;
}p[MAXN],S[MAXN];
int n,x,y,t,ans;
bool cmp(N a,N b){
if(a.x==b.x)return a.y<b.y;
return a.x<b.x;
}
int chk(N a,N b,N c){
N A,B;A.x=b.x-a.x;A.y=b.y-a.y;B.x=c.x-a.x;B.y=c.y-a.y;
return A.x*B.y-B.x*A.y>=0;
}
void add(N a){
while(t>0&&a.x==S[t-1].x)t--;
while(t>1&&chk(S[t-2],S[t-1],a))t--;
S[t++]=a;
}
int main(){
cin>>n;
for(int i=0;i<n;i++){
scanf("%d%d",&x,&y);
p[i].y=y-(ll)x*x;
p[i].x=x;
}
sort(p,p+n,cmp);
for(int i=0;i<n;i++)add(p[i]);
for(int i=0;i<t;i++)if(i==0||S[i].x!=S[i-1].x)ans++;
printf("%d",ans-1);
}
Codeforces Round #549 (Div. 2) F 数形结合 + 凸包(新坑)的更多相关文章
- Codeforces Round #536 (Div. 2) F 矩阵快速幂 + bsgs(新坑) + exgcd(新坑) + 欧拉降幂
https://codeforces.com/contest/1106/problem/F 题意 数列公式为\(f_i=(f^{b_1}_{i-1}*f^{b_2}_{i-2}*...*f^{b_k} ...
- CodeCraft-19 and Codeforces Round #537 (Div. 2) E 虚树 + 树形dp(新坑)
https://codeforces.com/contest/1111/problem/E 题意 一颗有n个点的树,有q个询问,每次从树挑出k个点,问将这k个点分成m组,需要保证在同一组中不存在一个点 ...
- Codeforces Round #549 (Div. 1)
今天试图用typora写题解 真开心 参考 你会发现有很多都是参考的..zblzbl Codeforces Round #549 (Div. 1) 最近脑子不行啦 需要cf来缓解一下 A. The B ...
- Codeforces Round #499 (Div. 1) F. Tree
Codeforces Round #499 (Div. 1) F. Tree 题目链接 \(\rm CodeForces\):https://codeforces.com/contest/1010/p ...
- [题解] Codeforces Round #549 (Div. 2) B. Nirvana
Codeforces Round #549 (Div. 2) B. Nirvana [题目描述] B. Nirvana time limit per test1 second memory limit ...
- Codeforces Round #485 (Div. 2) F. AND Graph
Codeforces Round #485 (Div. 2) F. AND Graph 题目连接: http://codeforces.com/contest/987/problem/F Descri ...
- Codeforces Round #486 (Div. 3) F. Rain and Umbrellas
Codeforces Round #486 (Div. 3) F. Rain and Umbrellas 题目连接: http://codeforces.com/group/T0ITBvoeEx/co ...
- Codeforces Round #501 (Div. 3) F. Bracket Substring
题目链接 Codeforces Round #501 (Div. 3) F. Bracket Substring 题解 官方题解 http://codeforces.com/blog/entry/60 ...
- Codeforces Round #376 (Div. 2)F. Video Cards(前缀和)
题目链接:http://codeforces.com/contest/731/problem/F 题意:有n个数,从里面选出来一个作为第一个,然后剩下的数要满足是这个数的倍数,如果不是,只能减小为他的 ...
随机推荐
- GC(二)CMS
什么是CMS CMS全称 Concurrent Mark Sweep,是一款并发的.使用标记-清除算法的垃圾回收器, 使用场景 GC过程短暂停,适合对时延要求较高的服务,用户线程不允许长时间的停顿. ...
- Mac流程图的软件
里面有破解机器,按照步骤一步步来就可以了 https://www.zhinin.com/omnigraffle_pro-mac.html
- Tomcat配置https访问
1.利用JDK自带的keytools生成一个p12类型的证书 keytool -genkey -storetype PKCS12 -alias tomcat -keyalg RSA -keysize ...
- Azure Automation (7) 执行Azure SQL Job
<Windows Azure Platform 系列文章目录> 之前Automation介绍的内容,是在ASM模式下自动化开关机. 本章将介绍如何在Automation中,设置开关机脚本, ...
- 大话设计模式Python实现-状态模式
状态模式(State Pattern):当一个对象的内在状态改变时允许改变其行为,这个对象看起来像是改变了其类 下面是一个状态模式的demo: #!/usr/bin/env python # -*- ...
- 如何取消 SqlDataAdapter.Fill() 的执行(转载)
问 Scenario: We have a DataGridView which is attached to DataAdapter (datatable), we load the data in ...
- Enum.GetUnderlyingType(obj.GetType())
Enum.GetUnderlyingType(obj.GetType())获取保存枚举值的数据类型:
- Kafka Network层解析,还是有人把它说清楚了
我们知道kafka是基于TCP连接的.其并没有像很多中间件使用netty作为TCP服务器.而是自己基于Java NIO写了一套. 几个重要类 先看下Kafka Client的网络层架构. 本文主要分析 ...
- Asp.Net MVC控制器获取视图传值几种方式
前台表单(V:视图) @{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="v ...
- Mac破解百度云
https://github.com/CodeTips/BaiduNetdiskPlugin-macOS