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 数形结合 + 凸包(新坑)的更多相关文章

  1. 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} ...

  2. CodeCraft-19 and Codeforces Round #537 (Div. 2) E 虚树 + 树形dp(新坑)

    https://codeforces.com/contest/1111/problem/E 题意 一颗有n个点的树,有q个询问,每次从树挑出k个点,问将这k个点分成m组,需要保证在同一组中不存在一个点 ...

  3. Codeforces Round #549 (Div. 1)

    今天试图用typora写题解 真开心 参考 你会发现有很多都是参考的..zblzbl Codeforces Round #549 (Div. 1) 最近脑子不行啦 需要cf来缓解一下 A. The B ...

  4. Codeforces Round #499 (Div. 1) F. Tree

    Codeforces Round #499 (Div. 1) F. Tree 题目链接 \(\rm CodeForces\):https://codeforces.com/contest/1010/p ...

  5. [题解] Codeforces Round #549 (Div. 2) B. Nirvana

    Codeforces Round #549 (Div. 2) B. Nirvana [题目描述] B. Nirvana time limit per test1 second memory limit ...

  6. Codeforces Round #485 (Div. 2) F. AND Graph

    Codeforces Round #485 (Div. 2) F. AND Graph 题目连接: http://codeforces.com/contest/987/problem/F Descri ...

  7. Codeforces Round #486 (Div. 3) F. Rain and Umbrellas

    Codeforces Round #486 (Div. 3) F. Rain and Umbrellas 题目连接: http://codeforces.com/group/T0ITBvoeEx/co ...

  8. Codeforces Round #501 (Div. 3) F. Bracket Substring

    题目链接 Codeforces Round #501 (Div. 3) F. Bracket Substring 题解 官方题解 http://codeforces.com/blog/entry/60 ...

  9. Codeforces Round #376 (Div. 2)F. Video Cards(前缀和)

    题目链接:http://codeforces.com/contest/731/problem/F 题意:有n个数,从里面选出来一个作为第一个,然后剩下的数要满足是这个数的倍数,如果不是,只能减小为他的 ...

随机推荐

  1. 数据仓库003 - 复习Linux shell命令 - 用户用户组 sudo 权限 du-sh find 

    一.用户用户组 [root@localhost ~]# ll /usr/sbin/user* -rwxr-x--- root root -- /usr/sbin/useradd -rwxr-x--- ...

  2. 物联网架构成长之路(34)-物联网数据可视化grafana展示

    一.前言 前面介绍了利用后台业务服务器监听EMQ的Topic,作为EMQ的一个客户端方式来保存数据.然后将数据保存到时序数据库InfluxDB中.本小节就简单介绍一下如何安装和使用,及如何利用Graf ...

  3. 获取Kafka每个分区最新Offset的几种方法

    目录 脚本方法 Java 程序 参考资料 脚本方法 ./bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhos ...

  4. (三十四)golang--接口

    golang的多态特性主要体现在接口上: 主要优势:高内聚低耦合: package main import ( "fmt" ) type usb interface { start ...

  5. LeetCode 160: 相交链表 Intersection of Two Linked Lists

    爱写Bug(ID:iCodeBugs) 编写一个程序,找到两个单链表相交的起始节点. Write a program to find the node at which the intersectio ...

  6. VMware exsi虚拟机磁盘扩容

    创建Linux时分配磁盘空间随着使用的增加,使用率逐渐升高,需要对/root进行扩容,此时需要在添加或者扩展一下磁盘. 查看Linux版本信息 [root@localhost ~]# cat /etc ...

  7. mysql float类型详解

    mysql float类型详解float类型长度必须设置3以上 不然会报错 out of range如果设置3 就只是 整数+小数的长度 比方说3.23 3.2等等 3.333就不行了 4位了

  8. Vue.js 源码分析(十八) 指令篇 v-for 指令详解

    我们可以用 v-for 指令基于一个数组or对象来渲染一个列表,有五种使用方法,如下: <!DOCTYPE html> <html lang="en"> & ...

  9. War 包部署

    Springboot 进行war包部署,以及踩坑历险!!! https://www.jianshu.com/p/4c2f27809571 Springboot2项目配置(热部署+war+外部tomca ...

  10. C#使用FileSystemWatcher来监控指定文件夹,并使用TCP/IP协议通过Socket发送到另外指定文件夹

    项目需求: 局域网内有两台电脑,电脑A(Windows系统)主要是负责接收一些文件(远程桌面粘贴.FTP上传.文件夹共享等方式),希望能在A接收文件后自动传输到电脑B(Windows系统)来做一个备份 ...