結果

問題 No.132 点と平面との距離
ユーザー fumofumofunifumofumofuni
提出日時 2020-12-09 13:03:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 277 ms / 5,000 ms
コード長 1,855 bytes
コンパイル時間 2,266 ms
コンパイル使用メモリ 207,288 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 04:50:05
合計ジャッジ時間 3,275 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
4,348 KB
testcase_01 AC 82 ms
4,348 KB
testcase_02 AC 277 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
struct P{
    double x,y,z;
};
vector<double> pleq(P a,P b,P c){
    vector<double> ret(4);
    ret[0]=(b.y-a.y)*(c.z-a.z)-(c.y-a.y)*(b.z-a.z);
    ret[1]=(b.z-a.z)*(c.x-a.x)-(c.z-a.z)*(b.x-a.x);
    ret[2]=(b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);
    ret[3]=-(ret[0]*a.x+ret[1]*a.y+ret[2]*a.z);
    return ret;
}
double dist(vector<double> c,P q){
    double ret=abs(c[0]*q.x+c[1]*q.y+c[2]*q.z+c[3]);
    ret/=sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2]);
    return ret;
}
int main(){
    ll n;cin >> n;
    P q;cin >> q.x >> q.y >> q.z;
    vector<P> p(n);
    rep(i,n){
        cin >> p[i].x >> p[i].y >> p[i].z;
    }
    double ret=0;
    rep(i,n){
        repl(j,i+1,n){
            repl(k,j+1,n){
                auto x=pleq(p[i],p[j],p[k]);
                ret+=dist(x,q);
            }
        }
    }
    CST(10);
    cout << ret <<endl;
}   
0