結果
| 問題 | No.132 点と平面との距離 |
| コンテスト | |
| ユーザー |
koyopro
|
| 提出日時 | 2020-01-04 23:18:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 72 ms / 5,000 ms |
| コード長 | 2,213 bytes |
| 記録 | |
| コンパイル時間 | 1,551 ms |
| コンパイル使用メモリ | 159,888 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-22 21:45:13 |
| 合計ジャッジ時間 | 2,154 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define array2(type, x, y) array<array<type, y>, x>
#define vector2(type) vector<vector<type> >
#define out(...) printf(__VA_ARGS__)
int dxy[] = {0, 1, 0, -1, 0};
/*================================*/
int N,M,L;
template<typename T> struct Pos {
T x, y, z;
Pos(){};
Pos(T _x, T _y): x(_x), y(_y){};
Pos(T _x, T _y, T _z): x(_x), y(_y), z(_z){};
Pos operator * (T t) {
return Pos(t * x, t * y);
}
Pos operator + (Pos q) {
return Pos(x + q.x, y + q.y, z + q.z);
}
Pos operator - (Pos q) {
return Pos(x - q.x, y - q.y, z - q.z);
}
int dot(Pos q) {
return x * q.x + y * q.y;
}
int det(Pos q) {
return x * q.y - y * q.x;
}
bool operator == (Pos q) {
return (x == q.x) && (y == q.y);
}
Pos operator * ( const Pos& q ) {
return Pos( y*q.z - z*q.y ,
z*q.x - x*q.z ,
x*q.y - y*q.x );
}
double operator % ( const Pos& q ) {
return ( x*q.x + y*q.y + z*q.z );
}
double norm() {
return sqrt(x*x + y*y + z*z);
}
};
typedef Pos<double> pos;
pos p;
vector<pos> X(444);
double dist(int i, int j, int k) {
pos a = X[i], b = X[j], c = X[k];
pos pa =a-p, pb=b-p, pc=c-p;
double v = (pa.y*pb.z*pc.x + pa.z*pb.x*pc.y + pa.x*pb.y*pc.z - pa.z*pb.y*pc.x - pa.x*pb.z*pc.y - pa.y*pb.x*pc.z)/6;
double s = ((b-a)*(c-a)).norm()/2;
return abs(3*v/s);
}
signed main()
{
#if DEBUG
std::ifstream in("input.txt");
std::cin.rdbuf(in.rdbuf());
#endif
cin>>N;
cin>>p.x>>p.y>>p.z;
REP(i,N)cin>>X[i].x>>X[i].y>>X[i].z;
double ans = 0;
FOR(i,0,N-2) FOR(j,i+1,N-1) FOR(k,j+1,N) {
ans += dist(i,j,k);
}
out("%.14f\n", ans);
return 0;
}
koyopro