結果
問題 | No.622 点と三角柱の内外判定 |
ユーザー | Pachicobue |
提出日時 | 2017-12-22 00:40:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,500 ms |
コード長 | 1,789 bytes |
コンパイル時間 | 2,119 ms |
コンパイル使用メモリ | 194,704 KB |
最終ジャッジ日時 | 2025-01-05 06:10:10 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 |
ソースコード
#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; }