結果
| 問題 | No.622 点と三角柱の内外判定 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-22 00:43:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,500 ms |
| コード長 | 867 bytes |
| 記録 | |
| コンパイル時間 | 1,819 ms |
| コンパイル使用メモリ | 194,160 KB |
| 最終ジャッジ日時 | 2025-01-05 06:10:20 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = double;
struct Vec {
ld dx;
ld dy;
ld dz;
ld dot(const Vec& v)
{
return (dx * v.dx + dy * v.dy + dz * v.dz);
}
};
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
ld x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4;
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> x3 >> y3 >> z3 >> x4 >> y4 >> z4;
Vec v1{x2 - x1, y2 - y1, z2 - z1};
Vec v2{x3 - x1, y3 - y1, z3 - z1};
Vec v3{x4 - x1, y4 - y1, z4 - z1};
const ld ab = v1.dot(v2);
const ld n1 = v1.dot(v1);
const ld n2 = v2.dot(v2);
const ld ac = v1.dot(v3);
const ld bc = v2.dot(v3);
const ld x = n2 * ac - ab * bc;
const ld y = -ab * ac + n1 * bc;
cout << (x > 0 and y > 0 and x + y < n1 * n2 - ab * ab ? "YES" : "NO") << endl;
return 0;
}