日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

CF535E Tavas and Pashmaks(凸包)

發布時間:2023/12/13 综合教程 31 生活家
生活随笔 收集整理的這篇文章主要介紹了 CF535E Tavas and Pashmaks(凸包) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題面

原題
翻譯

Solution

考慮對于每一個點,顯然R和S是沒有用的,對吧.
于是考慮一下對于每一個點可以維護一個類似于斜率的東西,然后搞一個凸包維護一下就好了.

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<queue>
#include<algorithm>
#define ll long long
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
using namespace std;
inline int gi(){
	int sum=0,f=1;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
inline ll gl(){
	ll sum=0,f=1;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
struct P{
	int x,y,id;
	bool operator<(const P RENA)const{
		return x>RENA.x || (x==RENA.x && y>RENA.y);
	}
}p[300010];
long double k[300010];
int q[300010],t,ne[300010],f[300010];
long double Slope(P a,P b){
	return (long double)a.x*b.x*(b.y-a.y)/((long double)a.y*b.y*(b.x-a.x));
}
int main(){
#ifndef ONLINE_JUDGE
	file("slay");
#endif
    int i,j,n,m;
	n=gi();int Y=0,X;
	for(i=1;i<=n;i++){
		p[i].x=gi();p[i].y=gi();p[i].id=i;
		if(Y<p[i].y || (Y==p[i].y && X<p[i].x))
			X=p[i].x,Y=p[i].y;
	}
	sort(p+1,p+n+1);q[t=1]=1;
	for(int i=2;i<=n && X<=p[i].x;i++){
		if(p[q[t]].x==p[i].x){
			if(p[q[t]].y==p[i].y){
				ne[p[i].id]=ne[p[q[t]].id];
				ne[p[q[t]].id]=p[i].id;
			}
			continue;
		}
		while(t>1 && k[t]>Slope(p[q[t]],p[i]))t--;
		q[++t]=i;k[t]=Slope(p[q[t-1]],p[i]);
	}
	for(;t;t--)
		for(i=p[q[t]].id;i;i=ne[i]){
			f[i]=1;
		}
	for(i=1;i<=n;i++)if(f[i])printf("%d ",i);
	puts("");
	return 0;
}

總結

以上是生活随笔為你收集整理的CF535E Tavas and Pashmaks(凸包)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。