結果

問題 No.199 星を描こう
ユーザー parukiparuki
提出日時 2016-08-20 20:32:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,071 bytes
コンパイル時間 1,680 ms
コンパイル使用メモリ 173,664 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 18:46:54
合計ジャッジ時間 2,767 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define EPS 1e-8
class V2{
public:
    double x, y;

    V2(){}
    V2(double x_, double y_):x(x_),y(y_){}

    bool operator<(const V2 &p) const{
        return x!=p.x?x<p.x:y<p.y;
    }
    V2 operator+(V2 p) const{
        return V2(add(x,p.x), add(y,p.y));
    }
    V2 operator-(V2 p) const{
        return V2(add(x,-p.x), add(y,-p.y));
    }
    double dist()const{
        return sqrt(x*x+y*y);
    }
private:
    double add(double a, double b)const{
        return abs(a+b)<EPS*(abs(a)+abs(b))?0:a+b;
    }
};
V2 operator *(double k, V2 p){
    p.x *= k;
    p.y *= k;
    return p;
}
double dot(const V2 & a, const V2 &b){
    return a.x*b.x + a.y*b.y;
}
double cross(const V2 &a, const V2 &b){
    return a.x * b.y - a.y * b.x;
}

int ccw(V2 a, V2 b, V2 c) {
    b = b-a; c = c-a;
    if(cross(b, c) > EPS) return +1;
    if(cross(b, c) < -EPS) return -1;
    if(dot(b, c) < -EPS) return +2;
    if (b.dist() < c.dist()) return -2;
    return 0;
}

vector<V2> convexHull(vector<V2> ps){
    int n = (int)ps.size();
    sort(begin(ps), end(ps));
    int k = 0;
    vector<V2> qs(n*2);
    for(int i=0; i<n; ++i){
        while(k > 1 && ccw(qs[k-2], qs[k-1], ps[i]) <= 0) k--;
        qs[k++] = ps[i];
    }
    for(int i=n-2, t=k; i>=0; --i){
        while(k>t && ccw(qs[k-2], qs[k-1], ps[i]) <= 0) k--;
        qs[k++] = ps[i];
    }
    qs.resize(k-1);
    return qs;
}

int main(){
    vector<V2> ps(5);
    rep(i, 5)cin >> ps[i].x >> ps[i].y;
    int num = sz(convexHull(ps));
    if(num == 5)cout << "YES" << endl;
    else cout << "NO" << endl;
}
0