結果

問題 No.622 点と三角柱の内外判定
ユーザー PachicobuePachicobue
提出日時 2017-12-22 00:40:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,500 ms
コード長 1,789 bytes
コンパイル時間 2,626 ms
コンパイル使用メモリ 198,828 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 21:13:00
合計ジャッジ時間 4,013 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = __int128_t;
using ld = long double;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;
constexpr ld PI = static_cast<ld>(3.1415926535898);

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;

struct Vec {
    ll dx;
    ll dy;
    ll dz;
    ll dot(const Vec& v)
    {
        return (dx * v.dx + dy * v.dy + dz * v.dz);
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long 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_;
    const ll x1 = x1_;
    const ll y1 = y1_;
    const ll z1 = z1_;
    const ll x2 = x2_;
    const ll y2 = y2_;
    const ll z2 = z2_;
    const ll x3 = x3_;
    const ll y3 = y3_;
    const ll z3 = z3_;
    const ll x4 = x4_;
    const ll y4 = y4_;
    const ll z4 = 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 ll ab = v1.dot(v2);
    const ll n1 = v1.dot(v1);
    const ll n2 = v2.dot(v2);
    const ll ac = v1.dot(v3);
    const ll bc = v2.dot(v3);
    const ll x = n2 * ac - ab * bc;
    const ll y = -ab * ac + n1 * bc;
    cout << (x > 0 and y > 0 and x + y < n1 * n2 - ab * ab ? "YES" : "NO") << endl;

    return 0;
}
0