結果

問題 No.199 星を描こう
ユーザー maine_honzukimaine_honzuki
提出日時 2020-12-18 10:06:20
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,380 bytes
コンパイル時間 2,315 ms
コンパイル使用メモリ 212,220 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 07:55:44
合計ジャッジ時間 4,263 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
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 AC 2 ms
4,348 KB
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 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

vector<pair<int, int>> convex_hull(vector<pair<int, int>> V) {
    auto cross = [](pair<int, int> a, pair<int, int> b, pair<int, int> c) {
        b.first -= a.first;
        c.first -= a.first;
        b.second -= a.second;
        c.second -= a.second;
        return (long long)b.first * c.second - (long long)b.second * c.first;
    };
    int n = (int)V.size();
    sort(V.begin(), V.end(), [](pair<int, int> a, pair<int, int> b) {
        return a.first != b.first ? a.first < b.first : a.second < b.second;
    });
    if (n == 1)
        return V;
    int k = 0;
    vector<pair<int, int>> ret(n * 2);
    for (int i = 0; i < n; i++) {
        while (k > 1 && cross(ret[k - 1], V[i], ret[k - 2]) >= 0)
            k--;
        ret[k++] = V[i];
    }
    for (int i = n - 2, t = k; i >= 0; i--) {
        while (k > t && cross(ret[k - 1], V[i], ret[k - 2]) >= 0)
            k--;
        ret[k++] = V[i];
    }
    ret.resize(k - 1);
    return ret;
}

int main() {
    vector<pair<int, int>> P(5);
    for (int i = 0; i < 5; i++) {
        cin >> P[i].first >> P[i].second;
    }

    bool flag = false;
    vector<int> perm(5);
    iota(perm.begin(), perm.end(), 0);
    do {
        flag |= convex_hull(P).size() == 5;
    } while (next_permutation(perm.begin(), perm.end()));

    cout << (flag ? "YES" : "NO") << endl;
}
0