結果
問題 | No.622 点と三角柱の内外判定 |
ユーザー |
![]() |
提出日時 | 2017-12-22 01:32:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,500 ms |
コード長 | 1,309 bytes |
コンパイル時間 | 656 ms |
コンパイル使用メモリ | 75,120 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-16 07:53:53 |
合計ジャッジ時間 | 1,486 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 |
ソースコード
#include <iostream>#include <vector>#include <string>#include <algorithm>#include <cstdio>#include <cstring>#include <cmath>using namespace std;struct P {double inner(const P& p) const {double t = 0;for (int i = 0; i < 3; i++) {t += x[i] * p.x[i];}return t;}P& operator-=(const P& p) {for (int i = 0; i < 3; i++) {x[i] -= p.x[i];}return *this;}P& operator*=(const double t) {for (int i = 0; i < 3; i++) {x[i] *= t;}return *this;}double x[3];};int main() {P p[4];for (int i = 0; i < 4; i++) {cin >> p[i].x[0] >> p[i].x[1] >> p[i].x[2];}P q[4];memcpy(q, p, sizeof p);int b = 1;for (int j = 0; j < 3; j++) {for (int i = 0; i < 3; i++) {p[i] = q[(i + j) % 3];}p[3] = q[3];for (int i = 0; i < 4; i++) {if (i != 2) p[i] -= p[2];}p[2] -= p[2];double t0 = p[0].inner(p[0]);double t1 = p[0].inner(p[1]);double r0 = sqrt(t0);p[1] -= (p[0] *= t1 / t0);double t = p[1].inner(p[3]);if (t < 0) b = 0;}cout << (b ? "YES" : "NO") << endl;return 0;}