結果
| 問題 | No.3154 convex polygon judge | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-05-20 21:46:19 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 74 ms / 2,000 ms | 
| コード長 | 1,170 bytes | 
| コンパイル時間 | 3,530 ms | 
| コンパイル使用メモリ | 284,808 KB | 
| 実行使用メモリ | 15,648 KB | 
| 最終ジャッジ日時 | 2025-05-20 21:46:25 | 
| 合計ジャッジ時間 | 5,065 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 44 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll cross(const pair<ll,ll> &O,
         const pair<ll,ll> &A,
         const pair<ll,ll> &B) {
    return (A.first - O.first) * (B.second - O.second)
         - (A.second - O.second) * (B.first - O.first);
}
vector<pair<ll,ll>> convex_hull(vector<pair<ll,ll>> P) {
    int n = P.size(), k = 0;
    if (n <= 1) return P;
    sort(P.begin(), P.end());
    vector<pair<ll,ll>> H(2*n);
    for (int i = 0; i < n; ++i) {
        while (k >= 2 && cross(H[k-2], H[k-1], P[i]) <= 0) k--;
        H[k++] = P[i];
    }
    for (int i = n-2, t = k+1; i >= 0; --i) {
        while (k >= t && cross(H[k-2], H[k-1], P[i]) <= 0) k--;
        H[k++] = P[i];
    }
    H.resize(k-1);
    return H;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<pair<ll,ll>> P(N);
    for(int i = 0; i < N; i++){
        cin >> P[i].first >> P[i].second;
    }
    if (N < 3) {
        cout << "No\n";
        return 0;
    }
    auto H = convex_hull(P);
    if ((int)H.size() == N) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}
            
            
            
        