题面
题解
左转板子,调个精度就能(A)了
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
R int res,f=1;R char ch;
while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
return res*f;
}
double readdb()
{
R double x=0,y=0.1,f=1;R char ch;
while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
for(x=ch-'0';(ch=getc())>='0'&&ch<='9';x=x*10+ch-'0');
for(ch=='.'&&(ch=getc());ch>='0'&&ch<='9';x+=(ch-'0')*y,y*=0.1,ch=getc());
return x*f;
}
const int N=105;const double eps=1e-10;
inline double Rd(){return 1.0*rand()/RAND_MAX;}
inline double reps(){return (Rd()-0.5)*eps;}
struct point{
double x,y,z;
point(){}
point(R double xx,R double yy,R double zz):x(xx),y(yy),z(zz){}
inline void init(){x=readdb()+reps(),y=readdb()+reps(),z=readdb()+reps();}
inline point operator -(const point &b)const{return point(x-b.x,y-b.y,z-b.z);}
inline point operator *(const point &b)const{return point(y*b.z-z*b.y,z*b.x-x*b.z,x*b.y-y*b.x);}
inline double operator ^(const point &b)const{return x*b.x+y*b.y+z*b.z;}
inline double norm()const{return sqrt(x*x+y*y+z*z);}
}p[N];
struct node{
int id[3];
node(){}
node(R int x,R int y,R int z){id[0]=x,id[1]=y,id[2]=z;}
inline point normal(){return (p[id[1]]-p[id[0]])*(p[id[2]]-p[id[0]]);}
inline double area(){return normal().norm()/2;}
inline bool ck(const point &b){return ((b-p[id[0]])^normal())>0;}
}f[N],st[N];
int vis[N][N],n,top,cnt,v;double res;
void Convex_3D(){
f[++cnt]=node(1,2,3),f[++cnt]=node(3,2,1);
fp(i,4,n){
top=0;
fp(j,1,cnt){
v=f[j].ck(p[i]),!v?(st[++top]=f[j],0):0;
vis[f[j].id[0]][f[j].id[1]]=
vis[f[j].id[1]][f[j].id[2]]=
vis[f[j].id[2]][f[j].id[0]]=v;
}
fp(j,1,cnt){
if(vis[f[j].id[0]][f[j].id[1]]&&!vis[f[j].id[1]][f[j].id[0]])st[++top]=node(i,f[j].id[0],f[j].id[1]);
if(vis[f[j].id[1]][f[j].id[2]]&&!vis[f[j].id[2]][f[j].id[1]])st[++top]=node(i,f[j].id[1],f[j].id[2]);
if(vis[f[j].id[2]][f[j].id[0]]&&!vis[f[j].id[0]][f[j].id[2]])st[++top]=node(i,f[j].id[2],f[j].id[0]);
}
fp(j,1,top)f[j]=st[j];cnt=top;
}
fp(i,1,cnt)res+=f[i].area();
printf("%.6lf
",res);
}
int main(){
// freopen("testdata.in","r",stdin);
n=read();
fp(i,1,n)p[i].init();
Convex_3D();
return 0;
}