結果
問題 | No.132 点と平面との距離 |
ユーザー |
|
提出日時 | 2022-05-10 22:24:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 5,000 ms |
コード長 | 1,311 bytes |
コンパイル時間 | 4,050 ms |
コンパイル使用メモリ | 257,648 KB |
最終ジャッジ日時 | 2025-01-29 05:38:31 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 |
ソースコード
#include<bits/stdc++.h>using namespace std;#include<atcoder/all>using namespace atcoder;using ll = long long;int n;using TUP = tuple<double,double,double>;TUP p;vector<TUP> q;double dist(TUP p,double a,double b,double c,double d){auto &[x,y,z] = p;return abs(a*x+b*y+c*z+d)/sqrt(a*a+b*b+c*c);}tuple<double,double,double,double> convert(TUP a,TUP b,TUP c){tuple<double,double,double,double> res;TUP ab,ac;{auto [a1,a2,a3] = a;auto [b1,b2,b3] = b;ab = TUP(b1-a1,b2-a2,b3-a3);}{auto [a1,a2,a3] = a;auto [c1,c2,c3] = c;ac = TUP(c1-a1,c2-a2,c3-a3);}{auto [a1,a2,a3] = ab;auto [b1,b2,b3] = ac;auto &[r1,r2,r3,r4] = res;r1 = a2*b3-a3*b2;r2 = a3*b1-a1*b3;r3 = a1*b2-b1*a2;{auto [a1,a2,a3] = a;r4 = -(a1*r1+a2*r2+a3*r3);}}return res;}void solve(){double ans = 0;for(int i = 0;i<n;i++){for(int j = i+1;j<n;j++){for(int k = j+1;k<n;k++){auto heimen = convert(q[i],q[j],q[k]);auto &[a,b,c,d] = heimen;//cerr<<a<<' '<<b<<' '<<c<<' '<<d<<endl;ans += dist(p,a,b,c,d);}}}printf("%.10lf\n",ans);}signed main(){cin.tie(nullptr);ios::sync_with_stdio(false);cin >> n;{auto &[x,y,z] = p;cin >> x >> y >> z;}q = vector<TUP>(n);for(auto &[x,y,z]:q)cin >> x >> y >> z;solve();}