結果

問題 No.199 星を描こう
ユーザー h_nosonh_noson
提出日時 2016-04-28 21:39:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 954 bytes
コンパイル時間 689 ms
コンパイル使用メモリ 63,344 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 18:46:09
合計ジャッジ時間 1,471 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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