結果

問題 No.622 点と三角柱の内外判定
ユーザー t98slidert98slider
提出日時 2023-07-20 02:02:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,028 bytes
コンパイル時間 1,864 ms
コンパイル使用メモリ 176,132 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 03:47:55
合計ジャッジ時間 2,882 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template<class T> struct point{
    T x, y;
    point(): x(0), y(0){}
    point(T a, T b): x(a), y(b){}
    point& operator += (const point& rhs) {x += rhs.x, y += rhs.y; return *this;}
    point& operator -= (const point& rhs) {x -= rhs.x, y -= rhs.y; return *this;}
    point& operator *= (const T& rhs) {x *= rhs, y *= rhs; return *this;}
    point& operator /= (const T& rhs) {x /= rhs, y /= rhs; return *this;}
    point operator +() const { return *this; }
    point operator -() const { return point() - *this; }
    friend point operator + (const point& lhs, const point& rhs) {return point(lhs) += rhs;}
    friend point operator - (const point& lhs, const point& rhs) {return point(lhs) -= rhs;}
    friend point operator * (const point& lhs, const T& rhs) {return point(lhs) *= rhs;}
    friend point operator * (const T& lhs, const point& rhs) {return point(rhs) *= lhs;}
    friend point operator / (const point& lhs, const T& rhs) {return point(lhs) /= rhs;}
    friend T operator * (const point& lhs, const point& rhs) {return lhs.x * rhs.x + lhs.y * rhs.y;}
    friend T operator ^ (const point& lhs, const point& rhs) {return lhs.x * rhs.y - lhs.y * rhs.x;}
    friend bool operator == (const point& lhs, const point& rhs) {return (lhs.x == rhs.x && lhs.y == rhs.y);}
    friend istream& operator >> (istream& os, point& rhs) noexcept {
        os >> rhs.x >> rhs.y;
        return os;
    }
    friend constexpr ostream& operator << (ostream &os, const point& rhs) noexcept {
        return os << '('<< rhs.x << ',' << rhs.y << ')';
    }
    double norm(){return sqrt(x * x + y * y);}
    T norm2(){return x * x + y * y;}
    int orthant(){//第何象限かのベクトルを返す(0,0は0象限とする)
        if(x == 0 && y == 0)return 0;
        if(y > 0)return (x > 0 ? 1 : 2);
        return (x > 0 ? 4 : 3);
    }
    //偏角ソート->ベクトルの大きさの小さい順の優先度
    friend bool operator < (point &lhs, point &rhs){//tupleとかでソートできないときは&を外すと良いかもしれない
        int lo = lhs.orthant(), ro = rhs.orthant();
        if(lo != ro)return (lo < ro);
        T cv = (lhs ^ rhs);
        if(cv != 0)return (cv > 0);
        return (lhs.norm2() < rhs.norm2());
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<array<ll, 4>> a(4);
    for(int i = 0; i < 4; i++){
        ll x, y, z;
        cin >> x >> y >> z;
        a[i] = {x, y, z};
    }
    for(int i = 0; i < 3; i++){
        vector<point<ll>> b(4);
        for(int j = 0; j < 4; j++){
            b[j] = {a[j][0], a[j][1]};
            rotate(a[j].begin(), a[j].begin() + 1, a[j].end());
        }
        vector<ll> c(3);
        for(int j = 0; j < 3; j++){
            c[j] = (b[(j + 1) % 3] - b[j]) ^ (b[3] - b[j]);
        }
        sort(c.begin(), c.end());
        if(c[0] * c[2] < 0){
            cout << "NO\n";
            exit(0);
        }
    }
    cout << "YES\n";
}
0