結果

問題 No.199 星を描こう
ユーザー koyoprokoyopro
提出日時 2015-10-02 13:45:44
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,101 bytes
コンパイル時間 1,483 ms
コンパイル使用メモリ 151,724 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-27 01:28:13
合計ジャッジ時間 2,903 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define ALL(a) (a).begin(),(a).end()
struct P {
    int x, y;
    P(){};
    P(int _x, int _y): x(_x), y(_y){};

    P operator - (P q) {
        return P(x - q.x, y - q.y);
    }
    int det(P q) {
        return x * q.y - y * q.x;
    }
};
vector<P> ps;

bool comp(P p, P q) {
    if (p.x != q.x) return p.x < q.x;
    return p.y < q.y;
}

vector<P> convex_hull(vector<P> *ps) {
    sort(ps->begin(), ps->end(), comp);
    vector<P> q(ps->size() * 2);
    int k = 0;
    REP(i,ps->size()) {
        if (k >= 2 && (q[k-1]-q[k-2]).det((*ps)[i]-q[k-1]) <= 0) k--;
        q[k++] = (*ps)[i];
    }
    int t = k;
    RREP(i,ps->size()-1) {
        if (k > t && (q[k-1]-q[k-2]).det((*ps)[i]-q[k-1]) <= 0) k--;
        q[k++] = (*ps)[i];
    }
    q.resize(k-1);
    return q;
}

signed main()
{
    int x,y;
    REP(i,5) {
        cin >> x >> y;
        ps.push_back(P(x,y));
    }
    cout << ((convex_hull(&ps).size() == 5) ? "YES" : "NO") << endl;
    return 0;
}
0