QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#518228#7521. Find the GapKLPP#Compile Error//C++171.7kb2024-08-13 18:32:142024-08-13 18:32:15

Judging History

This is the latest submission verdict.

  • [2024-08-13 18:32:15]
  • Judged
  • [2024-08-13 18:32:14]
  • Submitted

answer

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
typedef long long int lld;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)

typedef array<lld,3> pt;
vector<pt>pr;

typedef long double ld;

ld area(pt A, pt B){
	ld ans=0;
	rep(i,0,3){
		ld can=A[i]*B[(i+1)%3]-A[(i+1)%3]*B[i];
		can*=can;
		ans+=can;
	}
	return fsqrtl(ans);
}
ld mat[3][3];
int per[3];
ld vol(pt A, pt B, pt C){
	rep(i,0,3)mat[0][i]=A[i];
	rep(i,0,3)mat[1][i]=B[i];
	rep(i,0,3)mat[2][i]=C[i];
	rep(i,0,3)per[i]=i;
	ld ans=0;
	do{
		ld sign=1;
		rep(i,0,3){
			rep(j,i+1,3){
				if(per[i]>per[j])sign*=-1;
			}
		}
		ld can=1;
		rep(i,0,3){
			can*=mat[i][per[i]];
		}
		can*=sign;
		ans+=can;
	}while(next_permutation(per,per+3));
	return ans;
}

pt diff(pt A, pt B){
	return {A[0]-B[0],A[1]-B[1],A[2]-B[2]};
}

void solve(){
	int n;
	cin>>n;
	pr.resize(n);
	rep(i,0,n){
		rep(j,0,3)cin>>pr[i][j];
	}
	ld ans=1e18;
	bool ent=false;
	rep(i,0,n){
		rep(j,i+1,n){
			rep(k,j+1,n){
				ld Ar=area(diff(pr[j],pr[i]),diff(pr[k],pr[i]));
				if(Ar>1e-2){
					ent=true;
					ld Mn=0;
					ld Mx=0;
					rep(L,0,n){
						ld X=vol(diff(pr[j],pr[i]),diff(pr[k],pr[i]),diff(pr[L],pr[i]));
						Mn=min(Mn,X);
						Mx=max(Mx,X);
					}
					ans=min(ans,(Mx-Mn)/Ar);
				}
			}
		}
	}
	if(!ent)ans=0;
	cout<<fixed<<setprecision(10)<<ans<<"\n";
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int tt=1;
	//cin>>tt;
	while(tt--){
		solve();
	}
}

Details

answer.code: In function ‘ld area(pt, pt)’:
answer.code:24:16: error: ‘fsqrtl’ was not declared in this scope; did you mean ‘sqrtl’?
   24 |         return fsqrtl(ans);
      |                ^~~~~~
      |                sqrtl