cf 1142 C
忽然觉得这个题很有必要写题解。
移项
y-x^2 = bx+c
那么其实就是找有多少条直线上方没有点
所以就是一个上凸壳有多少条直线/点.
绝妙啊!!!!
太妙了啊!!!!
神乎其技卧槽!!!
(我是傻逼)
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
typedef long long db;
const double eps=1e-;
const double pi=acos(-);
int sign(db k){
if (k>eps) return ; else if (k<-eps) return -; return ;
}
int cmp(db k1,db k2){return sign(k1-k2);}
struct point{
db x,y;
point operator + (const point &k1) const{return (point){k1.x+x,k1.y+y};}
point operator - (const point &k1) const{return (point){x-k1.x,y-k1.y};}
point operator * (db k1) const{return (point){x*k1,y*k1};}
point operator / (db k1) const{return (point){x/k1,y/k1};}
bool operator == (const point &k1) const{return cmp(x,k1.x)==&&cmp(y,k1.y)==;}
bool operator <(const point &k1)const {
int c=cmp(x,k1.x);
if(c)return c==-;
return cmp(y,k1.y)==-;
}
};
db cross(point k1,point k2){return k1.x*k2.y-k1.y*k2.x;}
db dot(point k1,point k2){return k1.x*k2.x+k1.y*k2.y;}
int n;
vector<point> convexHull(vector<point> ps){
int n = ps.size();if(n<=)return ps;
sort(ps.begin(),ps.end());
vector<point> qs(n*);int k=;
for(int i=;i<n;qs[k++]=ps[i++])
while (k>&&cross(qs[k-]-qs[k-],ps[i]-qs[k-])<=)--k;
for(int i=n-,t=k;i>=;qs[k++]=ps[i--])
while (k>t&&cross(qs[k-]-qs[k-],ps[i]-qs[k-])<=)--k;
qs.resize(k-);
return qs;
}
void getUDP(vector<point>A,vector<point>&U,vector<point>&D){
db l=1e7,r=-1e7;
for (int i=;i<A.size();i++) l=min(l,A[i].x),r=max(r,A[i].x);
int wherel,wherer;
for (int i=;i<A.size();i++) if (cmp(A[i].x,l)==) wherel=i;
for (int i=A.size();i;i--) if (cmp(A[i-].x,r)==) wherer=i-;
U.clear(); D.clear(); int now=wherel;
while (){D.push_back(A[now]); if (now==wherer) break; now++; if (now>=A.size()) now=;}
now=wherel;
while (){U.push_back(A[now]); if (now==wherer) break; now--; if (now<) now=A.size()-;}
}
vector<point>p,u,d;
db x,y;
int main(){
scanf("%d",&n);
db mx=;
for(int i=;i<=n;i++){
scanf("%lld%lld",&x,&y);
p.push_back(point{x,y-x*x});
mx+=x;
}
p=convexHull(p);
getUDP(p,u,d);
set<int>s;
for(auto p:u)s.insert(p.x);
printf("%d\n",s.size()-);
}
cf 1142 C的更多相关文章
- ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'
凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...
- mysqldump: Got error: 1142: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'accounts' when using LOCK TABLES
AutoMySQLBackup备份时,出现mysqldump: Got error: 1142: SELECT, LOCK TABLES command denied to user 'root'@' ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- cf Round 613
A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...
- ARC下OC对象和CF对象之间的桥接(bridge)
在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...
- [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现
1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...
- CF memsql Start[c]UP 2.0 A
CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...
- CF memsql Start[c]UP 2.0 B
CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...
- CF #376 (Div. 2) C. dfs
1.CF #376 (Div. 2) C. Socks dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...
随机推荐
- flask学习(一)
特点: 短小精悍,可扩展性强 依赖wsgi:werkzurg werkzurg示例: from werkzeug.wrappers import Request, Response from werk ...
- Dubbo+Nacos做注册中心和配置中心
项目结构 相关代码 EchoService public interface EchoService { String echo(String msg); } DefaultEchoService @ ...
- C++入门篇六
struct和class的访问权限:结构体,类 struct和class 是相同的,唯一的而不同,就是默认权限,struct是public,class默认是private class Animal { ...
- flex布局学习
教程来自阮一峰的flex布局教程实例篇 容器五大属性: flex-direction:容器内项目的排列方向 (1)row:横向从左往右排列(默认) (2)row-reverse:横向从右往左排列 (3 ...
- C# 高级编程02----手动创建C#程序
在日常工作中使用C# 开发的时候,通常使用宇宙第一神器VS进行开发.为了了解编译过程,这里采用文本编辑器的方式编写一个C#程序 一.创建一个C#程序 1.使用记事本工具创建一个名为First.cs的文 ...
- 自己动手造拖拉机轮子系列 -(react-loadable)
最新消息:react官方已支持懒加载https://reactjs.org/docs/code-splitting.html#reactlazy 文章webpack分片chunk加载原理中深入探究了异 ...
- Helm - Kubernetes服务编排的利器
Helm介绍 在Kubernetes中部署容器云应用(容器或微服务编排)是一项有挑战性的工作,Helm就是为了简化在Kubernetes中安装部署容器云应用的一个客户端工具.通过Helm能够帮助开发者 ...
- C++11 带来的新特性 (2)—— 统一初始化(Uniform Initialization)
1 统一初始化(Uniform Initialization) 在C++ 11之前,所有对象的初始化方式是不同的,经常让写代码的我们感到困惑.C++ 11努力创造一个统一的初始化方式. 其语法是使用{ ...
- UOJ#424. 【集训队作业2018】count 多项式,FFT,矩阵
原文链接https://www.cnblogs.com/zhouzhendong/p/UOJ424.html 题解 主席太神仙了! 首先我们把题意转化成:对所有挺好序列建 笛卡尔树,有多少笛卡尔树互不 ...
- Linux中jdk的安装配置
1.下载jdk安装包 2.解压文件:tar -zxvf jdk-8u211-linux-x64.tar.gz 3.编辑环境变量:vi /etc/profile 4.在环境变量文末添加三行: expor ...