結果

問題 No.132 点と平面との距離
ユーザー GOTKAKO
提出日時 2025-07-13 05:49:37
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 991 bytes
コンパイル時間 1,974 ms
コンパイル使用メモリ 203,992 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-07-13 05:49:40
合計ジャッジ時間 2,623 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    double px,py,pz; cin >> px >> py >> pz;
    vector<tuple<double,double,double>> P(N);
    for(auto &[x,y,z] : P) cin >> x >> y >> z;
    
    vector V(N,vector<tuple<double,double,double>>(N));
    for(int i=0; i<N; i++) for(int k=i+1; k<N; k++){
        auto [x0,y0,z0] = P.at(i);
        auto [x1,y1,z1] = P.at(k);
        V.at(i).at(k) = {x1-x0,y1-y0,z1-z0};
    }

    double answer = 0;
    for(int i=0; i<N; i++) for(int k=i+1; k<N; k++){
        auto [x0,y0,z0] = P.at(i);
        auto [X0,Y0,Z0] = V.at(i).at(k);
        for(int l=k+1; l<N; l++){
            auto [X1,Y1,Z1] = V.at(i).at(l);
            double p = Y0*Z1-Y1*Z0,q = Z0*X1-Z1*X0,r = X0*Y1-X1*Y0;
            double s = -p*x0-q*y0-r*z0;
            answer += abs(p*px+q*py+r*pz+s)/sqrt(p*p+q*q+r*r);
        }
    }

    cout << fixed << setprecision(20) << answer << endl;
}
0