結果

問題 No.622 点と三角柱の内外判定
ユーザー PachicobuePachicobue
提出日時 2017-12-22 00:43:58
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,500 ms
コード長 867 bytes
コンパイル時間 1,987 ms
コンパイル使用メモリ 197,340 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 21:13:09
合計ジャッジ時間 3,177 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0