結果

問題 No.199 星を描こう
ユーザー h_noson
提出日時 2016-04-28 21:39:27
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 954 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 61,552 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-30 03:48:50
合計ジャッジ時間 3,117 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 RE * 2
other AC * 16 RE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

typedef pair<int,int> P;

int det(P a, P b) {
    return a.first * b.second - a.second * b.first;
}

P operator-(P a, P b) {
    return make_pair(a.first-b.first,a.second-b.second);
}

bool cmp(P a, P b) {
    if (a.first == b.first)
        return a.second > b.second;
    else
        return a.first < b.first;
}

int main() {
    int i, k, t;
    P p[5], out[5];
    for (i = 0; i < 5; i++) {
        int x, y;
        cin >> x >> y;
        p[i] = make_pair(x,y);
    }
    sort(p,p+5,cmp);
    k = 0;
    for (i = 0; i < 5; i++) {
        while (k > 1 && det(out[k-1]-out[k-2],p[i]-out[k-1]) <= 0) k--;
        out[k++] = p[i];
    }
    for (i = 4, t = k; i >= 0; i--) {
        while (k > t && det(out[k-1]-out[k-2],p[i]-out[k-1]) <= 0) k--;
        out[k++] = p[i];
    }
    k--;
    if (k == 5)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}
0