結果

問題 No.3100 Parallel Translated
ユーザー noya2
提出日時 2025-04-07 02:54:14
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,625 bytes
コンパイル時間 7,613 ms
コンパイル使用メモリ 275,344 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-04-11 20:50:18
合計ジャッジ時間 8,668 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other WA * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include"testlib.h"

#include <vector>
#include <numeric>
#include <set>
#include <utility>
using ll = long long;
const ll Nmin = 3;
const ll Nmax = 100;
const ll Xmin = -1'000'000;
const ll Xmax = +1'000'000;

struct P {
    ll x, y;
    friend P operator-(P a, P b){
        a.x -= b.x;
        a.y -= b.y;
        return a;
    }
};

ll cross(P a, P b){
    return a.x*b.y - a.y*b.x;
}

int main(){
    registerValidation();
    ll N = inf.readLong(Nmin, Nmax);
    inf.readEoln();
    std::vector<P> a(N);
    for (ll i = 0; i < N; i++){
        ll x = inf.readLong(Xmin, Xmax);
        inf.readSpace();
        ll y = inf.readLong(Xmin, Xmax);
        inf.readEoln();
        a[i] = {x,y};
    }
    inf.readEof();
    // ccw
    {
        for (ll i = 0; i < N; i++){
            ll j = (i + 1) % N;
            ll k = (i + 2) % N;
            ll cr = cross(a[j] - a[i], a[k] - a[j]);
            inf.ensuref(cr > 0, "ccw and not colinear");
        }
    }
    // distinct
    {
        std::set<std::pair<ll, ll>> st;
        for (auto [x, y] : a){
            st.insert({x, y});
        }
        inf.ensuref((ll)st.size() == N, "points are distinct");
    }
    // convex
    {
        for (ll i = 0; i < N; i++){
            ll j = (i + 1) % N;
            // all points are located at the same side partitioned by line a[i]-a[j]
            for (ll k = 0; k < N; k++){
                if (k == i || k == j) continue;
                ll cr = cross(a[j] - a[i], a[k] - a[j]);
                inf.ensuref(cr > 0, "convex");
            }
        }
    }
    // area is positive : cross(a[2] - a[1], a[1] - a[0]) > 0
}
0