結果

問題 No.199 星を描こう
ユーザー tubo28tubo28
提出日時 2015-05-15 13:21:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 4,846 bytes
コンパイル時間 1,319 ms
コンパイル使用メモリ 153,660 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-28 18:39:19
合計ジャッジ時間 2,462 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll
//#define endl "\n"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
template<class T> inline bool chmax(T & x, T const & y){ return x<y ? x=y,true : false; }
template<class T> inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif
// ll const mod = 1000000007;
// ll const inf = 1LL<<60;

typedef long double Real;
#define EPS (1e-10)
#define EQ(a,b) (abs(a-b) < EPS)
#define LE(a,b) (EQ(a,b) || a < b)
#define GE(a,b) (EQ(a,b) || b < a)

#define PCR Point const &
#define SCR Segment const &
#define LCR Line const &

struct Point {
    Real x, y;
    explicit Point (Real x_ = 0, Real y_ = 0);
    explicit Point (Real x_);
    Point operator + (PCR p) const;
    Point operator - (PCR p) const;
    Point operator * (PCR p) const;
    Point operator / (PCR p) const;
    Point operator * (Real k) const;
    Point operator / (Real k) const;
    bool operator < (PCR p) const;
    bool operator == (PCR p) const;
};
Real dot(PCR p, PCR q) { return p.x * q.x + p.y * q.y; }
Real cross(PCR p, PCR q) { return p.x * q.y - p.y * q.x; }
Real norm(PCR p){ return dot(p,p); }
Real abs(PCR p){ return sqrt(norm(p)); }
Point inv(PCR p){ return Point(p.x,-p.y) / abs(p); }
Real arg(PCR p){ return atan2(p.y,p.x); }
ostream & operator << (ostream & os, PCR p){ return os << "(" << p.x << "," << p.y << ")"; }
Point::Point (Real x_, Real y_) : x(x_), y(y_) {}
Point::Point (Real x_) : x(x_), y(0) {}
Point Point::operator + (PCR p) const { return Point(x + p.x, y + p.y); }
Point Point::operator - (PCR p) const { return Point(x - p.x, y - p.y); }
Point Point::operator * (PCR p) const { return Point(x*p.x - y*p.y, x*p.y + y*p.x); }
Point Point::operator / (PCR p) const { return Point(*this) * inv(p); }
Point Point::operator * (Real k) const { return Point(x * k, y * k); }
Point Point::operator / (Real k) const { return Point(x / k, y / k); }
bool Point::operator < (PCR p) const { return std::abs(x - p.x) < EPS ? x < p.x : y < p.y; }
bool Point::operator == (PCR p) const { return EQ(*this,p); }
bool comp_x(PCR p, PCR q){ return !EQ(p.x,q.x) ? p.x < q.x : p.y < q.y; }
bool comp_y(PCR p, PCR q){ return !EQ(p.y,q.y) ? p.y < q.y : p.x < q.x; }
struct Segment {
    Segment(Point a = Point(), Point b = Point()){ p[0] = a, p[1] = b; }
    Point p[2];
    Point & operator [] (int k) { return p[k]; }
    const Point & operator [] (int k) const { return p[k]; }
};

struct Line {
    Line(Point a = Point(), Point b = Point()){ p[0] = a, p[1] = b; }
    Point p[2];
    Point & operator [] (int k) { return p[k]; }
    const Point & operator [] (int k) const { return p[k]; }
};

struct Circle {
    Point p; Real r;
};

typedef vector<Point> Polygon;

enum {
    CCW = +1,
    CW = -1,
    BACK = +2,
    FRONT = -2,
    ON = 0
};
int ccw(PCR p0, PCR p1, PCR p2){
    Point a = p1 - p0;
    Point b = p2 - p0;
    if(cross(a,b) > EPS) return CCW;
    if(cross(a,b) < -EPS) return CW;
    if(dot(a,b) < -EPS) return BACK;
    if(norm(a) < norm(b)) return FRONT;
    return ON;
}

Polygon andrewScan(Polygon ps){
    int N = ps.size(), k = 0;
    sort(all(ps),comp_x);
    Polygon res(N*2);
    for(int i=0; i<N; i++) {
        while(k>=2 && ccw(res[k-2], res[k-1], ps[i])!=CCW) k--;
        res[k++] = ps[i];
    }
    int t = k+1;
    for(int i=N-2; i>=0; i--) {
        while(k>=t && ccw(res[k-2], res[k-1], ps[i])!=CCW) k--;
        res[k++] = ps[i];
    }
    res.resize(k-1);
    return res;
}


signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    Polygon p(5);
    rep(i,5){
        cin >> p[i].x >> p[i].y;
    }
    puts(andrewScan(p).size()==5 ? "YES" : "NO");
}
0