F. U2
题意:
输入
n
(
1
e
5
)
n(1e5)
n(1e5)
接下来输入
n
n
n行,每行
x
,
y
(
1
e
6
)
x,y(1e6)
x,y(1e6)表示一个点。
在平面任意两点都画一个二次函数
y
=
x
2
+
b
x
+
c
y=x^2+bx+c
y=x2+bx+c,问有多少个二次函数使其它的点不在它内部。
题解:
令 y = y 2 − x y=y^2-x y=y2−x,那么方程就变成了 y = b x + c y=bx+c y=bx+c,变成了一条直线,使其它经过变换的点都在它下面,其实就变成了求凸包上壳问题。
代码:
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+9;
#define ll long long
#define P pair<ll,ll>
P a[N];int n;
bool cmp(P p1,P p2){
if(p1.first!=p2.first)return p1.first<p2.first;
return p1.second>p2.second;
}
int q[N],hd,tl;
int main(){
//freopen("tt.in","r",stdin),freopen("tt.out","w",stdout);
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i].first>>a[i].second,a[i].second=a[i].second-a[i].first*a[i].first;
sort(a+1,a+n+1,cmp);
int hd=0,tl=-1;
for(int i=1;i<=n;i++){
if(tl!=-1&&a[q[tl]].first==a[i].first)continue;
while(tl>0&&(a[i].second-a[q[tl]].second)*(a[q[tl]].first-a[q[tl-1]].first)>=(a[i].first-a[q[tl]].first)*(a[q[tl]].second-a[q[tl-1]].second))tl--;
q[++tl]=i;
}
cout<<tl<<endl;
return 0;
}