自用模板

模板

#pragma GCC optimize(2)
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<utility>
#include<string.h>
#include<ext/rope> 
#include<queue>
#include<stack>
using namespace std;
using namespace __gnu_cxx;
#define int  long long
#define dnt double
#define rep(i,j,k) for(int i=(j);i<=(k);++i)
#define dow(i,j,k) for(int i=(j);i>=(k);--i)
#define pr pair
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false),cin.tie(NULL);
//int gp() {int x;while((x=rand())<=0)srand(time(0));return x%1000;}
inline int read(int &x) {
	x=0;int ff=1;char ch=getchar();
	while (ch<'0'||ch>'9') {
		if (ch=='-') ff=-1;ch=getchar();
	}
	while (ch>='0'&&ch<='9') {
		x=x*10+ch-48;ch=getchar();
	}
	x*=ff;
	return x;
}
void write(int x) {
  if (x > 9)write(x / 10);
  putchar((x % 10) + '0');
}
inline int max(int a,int b) {return a>b?a:b;}
inline int min(int a,int b) {return a>b?b:a;}
inline int exgcd(int a,int b,int&x,int&y) {
	if(b==0) {x=1,y=0 ;return a ;} 
	else {int r=exgcd(b,a%b,x,y);int t=x ;x=y ;y=t-a/b*y ;return r ;}
}
const int N=300005; 
struct SuffixAutoMaton{
    int last=1,cnt=1;int fa[N<<2],l[N<<2];
	int ch[N<<2][26];
	//map<int,int>ch[N<<2]; when needs to handle numbers
	int tong[N<<2];int pai[N<<2];
	int siz[N<<2];
    void ins(char c){
    	c-='a';
        int p=last,np=++cnt;last=np;l[np]=l[p]+1;
        for(;p&&!ch[p][c];p=fa[p])ch[p][c]=np;
        if(!p)fa[np]=1;
        else{
            int q=ch[p][c];
            if(l[p]+1==l[q])fa[np]=q;
            else{
                int nq=++cnt;l[nq]=l[p]+1;
                rep(i,0,25)
                ch[nq][i]=ch[q][i];
                fa[nq]=fa[q];fa[q]=fa[np]=nq;
                for(;ch[p][c]==q;p=fa[p])ch[p][c]=nq;
            }
        }
        siz[np]=1;
    }
    void ins(int c){
        int p=last,np=++cnt;last=np;l[np]=l[p]+1;
        for(;p&&!ch[p][c];p=fa[p])ch[p][c]=np;
        if(!p)fa[np]=1;
        else{
            int q=ch[p][c];
            if(l[p]+1==l[q])fa[np]=q;
            else{
                int nq=++cnt;l[nq]=l[p]+1;
                rep(i,0,25)
                ch[nq][i]=ch[q][i];
//				ch[nq]=ch[q]; // version when using std::map 
                fa[nq]=fa[q];fa[q]=fa[np]=nq;
                for(;ch[p][c]==q;p=fa[p])ch[p][c]=nq;
            }
        }
        siz[np]=1;
    }
    void calc_rcnt(){
        for(int i=1;i<=cnt;i++)tong[l[i]]++;
        for(int i=1;i<=cnt;i++)tong[i]+=tong[i-1];
        for(int i=1;i<=cnt;i++)pai[tong[l[i]]--]=i;
        for(int i=cnt;i;i--){
            int p=pai[i];
            siz[fa[p]]+=siz[p];
        }
    }
}sam;
/*
struct matrix {
	int n,m;
	int num[102][102];
	void pri() {
		for(int i=1; i<=n; i++) {
			for(int j=1; j<=m; j++) {
				cout<<num[i][j]<<" ";
			}
			cout<<endl;
		}
	}
	matrix operator*(matrix y) {
		matrix x=*this;
		matrix c;
		c.n=x.n;
		c.m=y.m;
		memset(c.num,0,sizeof(c.num));
		for(int i=1; i<=x.n; i++) {
			for(int k=1; k<=x.m; k++){
				if(x.num[i][k])
				for(int j=1; j<=y.m; j++){
				c.num[i][j]+=x.num[i][k]*y.num[k][j];
				//	c.num[i][j]+=((x.num[i][k]%mod)*(y.num[k][j]%mod))%mod;
				}
			}
		}
		return c;
	}
	matrix operator ^ (int x) {
		matrix c,xx;
		xx=*this;
		c.m=xx.m;
		c.n=xx.n;
		for(int i=1; i<=xx.n; i++)
			for(int j=1; j<=xx.m; j++)
				c.num[i][j]=(i==j);
		for(; x; x>>=1) {
			if(x&1)
				c=c*xx;
			xx=xx*xx;
		}
		return c;
	}
};*/
int fpow(int x,int y) { 
	int ans=1;int base=x;
	while(y) {
		if(y&1)ans=ans*base;
		y/=2;base=base*base;
	}
	return ans;
}
int mod=1e9+7;
const int maxn=600005;
/*int lim=maxn,tot=0;int prime[maxn];int dr[maxn];
void shai() {
	for(int i=2; i<=lim; i++) {if(dr[i] == 0) {prime[++tot] = i;dr[i]=i;}
		for(int j=1; j<=tot && i * prime[j] <=lim; j++) {dr[i * prime[j]] = prime[j];if(i % prime[j] == 0) break;}}
} */
int head[maxn];
int id=0;
struct Edge {
	int w,v,next;
} e[maxn*5];
void build(int u,int v,int w) {
	e[++id].v=v;
	e[id].w=w;
	e[id].next=head[u];
	head[u]=id;return; 
}
int f[maxn],a[maxn];int n,m,k;
void solve(){
	
}
signed main() {
	//freopen("data.in","r",stdin);
	//freopen("T1.out","w",stdout);

	return 0;
}
/*



*/
color A 
echo off 
:loop
	echo 已运行%a%次
	set /a a+=1
	datacreator.exe
	T1.exe 
	std.exe 
	fc T1.out std.out 
	if not errorlevel 1 goto loop
pause

洛谷模板

#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<string.h>
#include<queue>
#include<stack>
using namespace std;
#define int  long long
#define dnt double
#define rep(i,j,k) for(int i=(j);i<=(k);++i)
#define dow(i,j,k) for(int i=(j);i>=(k);--i)
#define pr pair
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
//int gp() {int x;while((x=rand())<=0)srand(time(0));return x%1000;}
inline int read(int &x) {
	x=0;int ff=1;char ch=getchar();
	while (ch<'0'||ch>'9') {
		if (ch=='-') ff=-1;ch=getchar();
	}
	while (ch>='0'&&ch<='9') {
		x=x*10+ch-48;ch=getchar();
	}
	x*=ff;
	return x;
}
void write(int x) {
  if (x > 9)write(x / 10);
  putchar((x % 10) + '0');
}
inline int max(int a,int b) {return a>b?a:b;}
inline int min(int a,int b) {return a>b?b:a;}
inline int exgcd(int a,int b,int&x,int&y) {
	if(b==0) {x=1,y=0 ;return a ;} 
	else {int r=exgcd(b,a%b,x,y);int t=x ;x=y ;y=t-a/b*y ;return r ;}
}
const int N=1000005;
/*struct SuffixAutoMaton{
    int last=1,cnt=1;int ch[N<<1][26],fa[N<<1],l[N<<1];
	int tong[N<<1];int pai[N<<1];int siz[N<<1];
    void ins(int c){
        int p=last,np=++cnt;last=np;l[np]=l[p]+1;
        for(;p&&!ch[p][c];p=fa[p])ch[p][c]=np;
        if(!p)fa[np]=1;
        else{
            int q=ch[p][c];
            if(l[p]+1==l[q])fa[np]=q;
            else{
                int nq=++cnt;l[nq]=l[p]+1;
                rep(i,0,25)
                ch[nq][i]=ch[q][i];
                fa[nq]=fa[q];fa[q]=fa[np]=nq;
                for(;ch[p][c]==q;p=fa[p])ch[p][c]=nq;
            }
        }
        siz[np]=1;
    }
        void sortt(){
        for(int i=1;i<=cnt;i++)tong[l[i]]++;
        for(int i=1;i<=cnt;i++)tong[i]+=tong[i-1];
        for(int i=1;i<=cnt;i++)pai[tong[l[i]]--]=i;
        for(int i=cnt;i;i--){
            int u=pai[i];
        }
    }
}sam;*/
/*
struct matrix {
	int n,m;
	int num[102][102];
	void pri() {
		for(int i=1; i<=n; i++) {
			for(int j=1; j<=m; j++) {
				cout<<num[i][j]<<" ";
			}
			cout<<endl;
		}
	}
	matrix operator*(matrix y) {
		matrix x=*this;
		matrix c;
		c.n=x.n;
		c.m=y.m;
		memset(c.num,0,sizeof(c.num));
		for(int i=1; i<=x.n; i++) {
			for(int k=1; k<=x.m; k++){
				if(x.num[i][k])
				for(int j=1; j<=y.m; j++){
				c.num[i][j]+=x.num[i][k]*y.num[k][j];
				//	c.num[i][j]+=((x.num[i][k]%mod)*(y.num[k][j]%mod))%mod;
				}
			}
		}
		return c;
	}
	matrix operator ^ (int x) {
		matrix c,xx;
		xx=*this;
		c.m=xx.m;
		c.n=xx.n;
		for(int i=1; i<=xx.n; i++)
			for(int j=1; j<=xx.m; j++)
				c.num[i][j]=(i==j);
		for(; x; x>>=1) {
			if(x&1)
				c=c*xx;
			xx=xx*xx;
		}
		return c;
	}
};*/
int fpow(int x,int y) { 
	int ans=1;int base=x;
	while(y) {
		if(y&1)ans=ans*base;
		y/=2;base=base*base;
	}
	return ans;
}
int mod=1e9+7;
const int maxn=500001;
/*int lim=maxn,tot=0;int prime[maxn];int dr[maxn];
void shai() {
	for(int i=2; i<=lim; i++) {if(dr[i] == 0) {prime[++tot] = i;dr[i]=i;}
		for(int j=1; j<=tot && i * prime[j] <=lim; j++) {dr[i * prime[j]] = prime[j];if(i % prime[j] == 0) break;}}
} */
int head[maxn];
int id=0;
struct Edge {
	int w,v,next;
} e[maxn*5];
void build(int u,int v,int w) {
	e[++id].v=v;
	e[id].w=w;
	e[id].next=head[u];
	head[u]=id;return; 
}
int f[maxn],a[maxn];int n,m,k;
//加油 注意初始化
void solve(){
	
}
signed main() {
	ios::sync_with_stdio(false),cin.tie(NULL);
	//freopen("data.in","r",stdin);
	//freopen("T1.out","w",stdout);
	int t;
	cin>>t;
	while(t--){
		solve();
	} 

	return 0;
}
/*



*/
/*
235302
8efe95dfdb49abf1345db042db63a466bfa5373f
*/

简单模板

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,j,k) for(int i=(j);i<=(k);++i)
#define dow(i,j,k) for(int i=(j);i>=(k);--i)
#define pr pair
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
inline int read(int &x) {
	x=0;int ff=1;char ch=getchar();
	while (ch<'0'||ch>'9') {
		if (ch=='-') ff=-1;ch=getchar();
	}
	while (ch>='0'&&ch<='9') {
		x=x*10+ch-48;ch=getchar();
	}
	x*=ff;
	return x;
}
void write(int x) {
  if (x > 9)write(x / 10);
  putchar((x % 10) + '0');
}
int max(int a,int b) {return a>b?a:b;}
int min(int a,int b) {return a>b?b:a;}
int exgcd(int a,int b,int&x,int&y) {
	if(b==0) {x=1,y=0 ;return a ;} 
	else {int r=exgcd(b,a%b,x,y);int t=x ;x=y ;y=t-a/b*y ;return r ;}
}
int fpow(int x,int y) { 
	int ans=1;int base=x;
	while(y) {
		if(y&1)ans=ans*base;
		y/=2;base=base*base;
	}
	return ans;
}
int mod=1e9+7;
const int maxn=500001;
int f[maxn],a[maxn];int n,m,k;
signed main() {
	ios::sync_with_stdio(false),cin.tie(NULL);
	//freopen("data.in","r",stdin);
	//freopen("T1.out","w",stdout);

	return 0;
}
/*



*/

重置程序

#include<bits/stdc++.h>
using namespace std;
int op; 
void copyFile() {
	char c[6][7]= {"T1.cpp","T2.cpp","T3.cpp","T4.cpp","T5.cpp","T6.cpp"};
	for(int i=0; i<=5; i++) {
		FILE *in, *out;
		char ch ;
		if(op==1){
			if ((in = fopen("模板.cpp","r")) == NULL) { //in.txt 和out.txt 都在当前工作目录下存放
			printf("canot find the in.txt file!\n");
			exit(0);
			}
		}
		else if(op==2){
		if ((in = fopen("洛谷模板.cpp","r")) == NULL) { //in.txt 和out.txt 都在当前工作目录下存放
			printf("canot find the in.txt file!\n");
			exit(0);
			}	
		}
		else if(op==3){
		if ((in = fopen("简单模版.cpp","r")) == NULL) { //in.txt 和out.txt 都在当前工作目录下存放
			printf("canot find the in.txt file!\n");
			exit(0);
			}	
		}
		else{
			cout<<"error"<<endl;
			return;
		}
		if ((out = fopen(c[i],"w"))==NULL) { // 写入数据的文件
			printf("canot find the out.txt file!\n");
			exit(0);
		}
		ch = fgetc(in);
		while (ch!=EOF) {
			fputc(ch,out);
			putchar(ch); //是in.txt 的内容显示在dos窗口 下
			ch = fgetc(in);
		}
		fclose(in); // 关闭文件
		fclose(out);
	}
	char ss[]="datacreator.cpp";
	FILE *in, *out;
		char ch ;
		if ((in = fopen("datacreator模板.cpp","r")) == NULL) { 
			printf("canot find the in.txt file!\n");
			exit(0);
		}

		if ((out = fopen(ss,"w"))==NULL) {
			printf("canot find the out.txt file!\n");
			exit(0);
		}
		ch = fgetc(in);
		while (ch!=EOF) {
			fputc(ch,out);
			putchar(ch); 
			ch = fgetc(in);
		}
		fclose(in); 
		fclose(out); 

}
int main() {
	cout<<"please choose type of model 1 for classic ,2 for luogu.com,3 for succinct version"<<endl;
	cin>>op;
	cout<<op<<endl;
	copyFile() ;
	puts("");
	return 0;
}

计算几何(求二维凸包为例)

#define _USE_MINGW_ANSI_STDIO 1
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
//#define double long double
#define rep(i,j,k) for(int i=(j);i<=(k);++i)
#define dow(i,j,k) for(int i=(j);i>=(k);--i)
#define pr pair
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
namespace geo_2d{
//template<typename T>
//T min(T a,T b){
//	return a>b?b:a;
//}
//template<typename T>
//T max(T a,T b){
//	return a>b?a:b;
//}
const double eps=1e-9, INF=1e18, PI=3.14159265358979323846;
struct V{
    double x, y;
    V():x(0),y(0){}
    V(const V &a){ *this=a; }
    V(const double &a, const double &b):x(a),y(b){}
    void rot90(){ double b=x;x=-y;y=b;}
    void read(){ scanf("%lf%lf", &x, &y); }
    void print(){ printf("%.9lf %.9lf\n", x, y); }  //位数多精度高
    void print_space(){ printf("%.9lf %.9lf ", x, y); }
    void print_int(){ printf("%d %d\n", (int)x, (int)y); }
    void print_g(){ printf("%g %g\n", x, y); }
}O;  
 bool zero(const double &x){ return abs(x)<eps; }
 bool equal(const double &a, const double &b){ return zero(a-b); }
 bool less(const double &a, const double &b){ return a<b-eps; }  //更严格
 bool greater(const double &a, const double &b){ return a>b+eps; }
 bool in(const double &a, const double &l, const double &r){
    if (l<r){
    	return !geo_2d::less(a, l)&&!geo_2d::greater(a, r);//a>b&&a<c
	} 
    else return !geo_2d::greater(a, l)&&!geo_2d::less(a, r);//a<b&&a>c
}

 V operator-(const V &a){ return V(-a.x, -a.y); }
 V operator+(const V &a, const V &b){ return V(a.x+b.x, a.y+b.y); }
 V operator-(const V &a, const V &b){ return V(a.x-b.x, a.y-b.y); }
 V operator*(const double &x, const V &a){ return V(a.x*x, a.y*x); }
 V operator*(const V &a, const double &x){ return V(a.x*x, a.y*x); }
 V operator/(const V &a, const double &x){ return V(a.x/x, a.y/x); }
 bool operator==(const V &a, const V &b){ return equal(a.x, b.x)&&equal(a.y, b.y);}
 bool operator!=(const V &a, const V &b){ return !(a==b); }
 double operator*(const V &a, const V &b){ return a.x*b.x+a.y*b.y; }
 double operator^(const V &a, const V &b){ return a.x*b.y-a.y*b.x; }
 double len(const V &a){ return sqrt(a.x*a.x+a.y*a.y); }
 double dis(const V &a, const V &b){ return len(a-b); }
 V mid(const V &a, const V &b){ return V((a.x+b.x)/2, (a.y+b.y)/2); }
 V c_wise(const V &a){ return V(a.y, -a.x); }
 V cc_wise(const V &a){ return V(-a.y, -a.x); }
 V unit(const V &a){ return a/len(a); }
 bool in(const V &a, const V &l, const V &r){
	if(!zero((a-l)^(a-r)))
	return 0;
	return in(a.x,l.x,r.x)&&in(a.y,l.y,r.y);
}
struct L{  //记录单位方向向量+两点,也可以用来表示线段
    V d, a, b;
    L(){}
    L(const V &x1, const V &x2, const V &x3):d(x1),a(x2),b(x3){}
    L(const V &x, const V &y){ *this=L(y-x, x, y); }
    L(const V &d){ *this=L(d, V(0,0), d); }
    void print(){ d.print_space(); a.print_space(); b.print_space(); puts("");}
};
 V priject(const V &p, const L &l){ //p到l的投影点 
    return l.a+((p-l.a)*unit(l.d))*unit(l.d);
}
 V reflect(const V &p, const L &l){//p关于l的对称点 
    return 2*priject(p, l)-p;
}
 bool on_line(const V &p, const L &l){//p是否与l共线 
    return zero(l.d^(p-l.a));
}
 bool on_seg(const V &p, const L &l){//p是否在l上 
    return zero(dis(p, l.a)+dis(p, l.b)-dis(l.a, l.b));
}
 double dis(const V &p, const L &l){//p到l直线的距离 
    return abs((p-l.a)^(p-l.b))/dis(l.a, l.b);
}
 double dis2(const V &p, const L &l){  //带符号距离
    return ((p-l.a)^(p-l.b))/dis(l.a, l.b);
}
 bool collinear(const V &a, const V &b){ return zero(a^b); }//判断共线 
 bool orthogonal(const V &a, const V &b){ return zero(a*b); }//判断垂直 
 bool parallel(const L &l1, const L &l2){ return zero(l1.d^l2.d); }
 bool orthogonal(const L &l1, const L &l2){ return zero(l1.d*l2.d); }
 bool straddle(const L &l1, const L &l2){  //判断l1是否跨立在l2上
    double f1=(l1.a-l2.a)^l2.d;
    double f2=(l1.b-l2.a)^l2.d;
    if (f1*f2<eps) return true;
    else return false;
}
 bool is_intersect2(const L &l1, const L &l2){  //直线与线段相交,l1为直线
    double a=(l2.a-l1.a)^l1.d, b=(l2.b-l1.a)^l1.d;
    if (!less(a, 0)&&!greater(b, 0)) return true;
    if (!greater(a, 0)&&!less(b, 0)) return true;
    return false;
}
 bool is_intersect(const L &l1, const L &l2){  //线段相交
    if (greater(min(l1.a.x, l1.b.x), max(l2.a.x, l2.b.x))||
        less(max(l1.a.x, l1.b.x), min(l2.a.x, l2.b.x))||
        greater(min(l1.a.y, l1.b.y), max(l2.a.y, l2.b.y))||
        less(max(l1.a.y, l1.b.y), min(l2.a.y, l2.b.y)))
            return false;
    //以上是快速排斥
    return straddle(l1, l2)&&straddle(l2, l1);
}  //先考虑l1跨立在l2上,再考虑l2跨立在l1上
 V intersection(const L &l1, const L &l2){//求交点 
    double k=((l2.a-l1.a)^l2.d)/(l1.d^l2.d);
    return l1.a+k*l1.d;
}
 L bisector(const V &a, const V &b, const V &c){  //angleBAC 中线 
    V d1=(b-a)/len(b-a), d2=(c-a)/len(c-a);
    V d=(d1+d2)/len(d1+d2);
    return L(d, a, a+d);
}
//多边形 
 double L_polygon(const V *a, const int &n){
    double res=0;
    for (int i=0; i<n; ++i) res+=dis(a[i], a[(i+1)%n]);
    return res;
}
 double S_polygon(const V *a, const int &n){
	//要求a中点按照时针顺序给出,将答案abs去掉则要求逆时针给出 
    double res=0;
    for (int i=0; i<n; ++i) res+=(a[i]^a[(i+1)%n]);
    return abs(res/2);
}
 void read_polygon(V *a, int &n, bool with_n){
    if (with_n) scanf("%d", &n);
    for (int i=0; i<n; ++i) a[i].read();
}
 bool is_convex(const V *a, const int &n){
	//是否为凸四边形 要求顺序输入 
    int j, k, d=0, nd; double o;
    for (int i=0; i<n; ++i){
        j=(i+1)%n, k=(i+2)%n;
        o=(a[j]-a[i])^(a[k]-a[j]);
        if (zero(o)) continue;
        nd=less(o, 0)?-1:1;
        if (!d) d=nd;
        else if (d!=nd) return false;
    }
    return true;
}
 int in_poly( const V &p,const V *a,const  int &n){
	//点与任意四边形关系 2在边上 1在内部 0在外部 要求顺序输入 使用水平射线,无视重合线段 
    double x; int j, res=0;
    for (int i=0; i<n; ++i){
        j=(i+1)%n;
        if(in(p,a[i],a[j]))
        return 2;
        if (equal(a[i].y, a[j].y)) continue;
        if (less(max(a[i].y, a[j].y), p.y)) continue;
        if (!less(min(a[i].y, a[j].y), p.y)) continue;
        x=a[i].x+(p.y-a[i].y)/(a[j].y-a[i].y)*(a[j].x-a[i].x);
        if (x<p.x) res^=1;
    }
    return res?true:false;
}

 bool turn_right(const V &p1, const V &p2, const V &p3){  //p1指向p2,p2指向p3,前面乘后面
    return less((p2-p1)^(p3-p2), 0);
}
 bool turn_left(const V &p1, const V &p2, const V &p3){
    return greater((p2-p1)^(p3-p2), 0);
}
bool cmp_xy(V x,V y){
	return x.x==y.x?(x.y<y.y):(x.x<y.x);
} 	
void andrew(V *a, int &n, bool include_on_edge){
    vector<int>vis(n);
    vector<int>s(n+1);
    vector<V>temp(n);
 	sort(a,a+n,cmp_xy);
    int cnt=0, id1, id2;
    for (int i=0; i<n; ++i){
    	temp[i]=a[i];
        while (cnt>=2){
            id1=s[cnt-1]; id2=s[cnt-2];
            if (include_on_edge){
                if (!turn_right(a[id2], a[id1], a[i])) break;
            } else if (turn_left(a[id2], a[id1], a[i])) break;
            vis[s[cnt-1]]=0;
            --cnt;
        }
         s[cnt++]=i;
         vis[i]=1;
    }
    int k=cnt;
    for (int i=n-2; i>=0; --i){
    	if(vis[i]&&i)
    	continue;
        while (cnt>k){
            id1=s[cnt-1]; id2=s[cnt-2];
            if (include_on_edge){
                if (!turn_right(a[id2], a[id1], a[i])) break;
            } else if (turn_left(a[id2], a[id1], a[i])) break;
            --cnt;
        }
        s[cnt++]=i;
    }
     n=cnt-1;
     cnt--;
    for (int i=0; i<cnt; ++i){
    	a[i]=temp[s[i]];
	}
}

inline void adjust_lowest(V *a, const int &n){  //逆时针凸包调整为起始点为最低点 
	int id=0;
	vector<V> b(n);
    for (int i=0; i<n; ++i)
        if (less(a[i].y, a[id].y)||
                equal(a[i].y, a[id].y)&&less(a[i].x, a[id].x)) id=i;
    
    for (int i=0; i<n; ++i) b[i]=a[(i+id)%n];
    for (int i=0; i<n; ++i) a[i]=b[i];
}
};
//using namespace geo_2d;
int q;
geo_2d::V dots[105000];
geo_2d::V p; 
signed main() {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		dots[i].read();
	}
	if(n<=2){
		if(n==1){
			cout<<0.00<<endl;
		}
		else{
			printf("%.2lf",dis(dots[0],dots[1]));
		}
		return 0;
	}
	geo_2d::andrew(dots,n,1);
//	printf("%.6lf",geo_2d::S_polygon(dots,n)); 
	printf("%d\n",n);
	geo_2d::adjust_lowest(dots,n);
	for(int i=0;i<n;i++){
		dots[i].print_g();
	}
	return 0;
}
/*
10 
5 0
0 0
2 0 
6 0 
9 0 
8 0 
1 0
7 0
4 0
3 0
*/ 
posted @ 2023-07-11 18:28  wxk123  阅读(31)  评论(0)    收藏  举报