結果
| 問題 |
No.199 星を描こう
|
| コンテスト | |
| ユーザー |
snuke
|
| 提出日時 | 2015-04-29 00:21:05 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 4,241 bytes |
| コンパイル時間 | 1,132 ms |
| コンパイル使用メモリ | 87,640 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-30 03:23:17 |
| 合計ジャッジ時間 | 1,921 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rrep(i,n) for(int i = 1; i <= n; ++i)
#define drep(i,n) for(int i = n-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi& a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
const int MX = 100005, INF = 1000010000;
const ll LINF = 1000000000000000000ll;
const int di[] = {-1,0,1,0}, dj[] = {0,-1,0,1}; //^<v>
// geom
#include <cmath>
const double inf = 1e6;
const double eps = 1e-9;
const double PI = acos(-1.0);
inline double toRad(double deg){ return deg * PI / 180.0;}
struct V {
double x, y;
V(double x=0, double y=0):x(x),y(y){}
V operator+(V t) { return V(x+t.x,y+t.y);}
V operator-(V t) { return V(x-t.x,y-t.y);}
V operator*(double t) { return V(x*t,y*t);}
V operator/(double t) { return V(x/t,y/t);}
double dot(V t) { return x*t.x + y*t.y;}
double cross(V t) { return x*t.y - y*t.x;}
double norm2() { return x*x + y*y;}
double norm() { return sqrt(x*x + y*y);}
V rev() { return V(-x,-y);}
V normalize() { return V(x/norm(), y/norm());}
V rotate90() { return V(-y,x);}
V rotate(V a, double rad){
return V(a.x + cos(rad)*(x-a.x) - sin(rad)*(y-a.y),
a.y + sin(rad)*(x-a.x) + cos(rad)*(y-a.y));
}
bool operator<(V a)const { return abs(x - a.x) > eps ? x < a.x : y < a.y;}
bool operator==(V a)const { return abs(x - a.x) < eps && abs(y - a.y) < eps;}
};
struct Line {
V s, t;
Line(V s=V(0,0), V t=V(0,0)):s(s),t(t){}
V dir() { return t-s;}
V normalize() { return dir().normalize();}
double norm() { return dir().norm();}
/* +1: s-t,s-p : ccw
* -1: s-t,s-p : cw
* +2: t-s-p
* -2: s-t-p
* 0: s-p-t */
int ccw(V p) {
if (dir().cross(p-s) > eps) return +1;
if (dir().cross(p-s) < -eps) return -1;
if (dir().dot(p-s) < -eps) return +2;
if (dir().norm()+eps < (p-s).norm()) return -2;
return 0;
}
bool touch(Line l) {
int a = ccw(l.s)*ccw(l.t), b = l.ccw(s)*l.ccw(t);
return !a || !b || (a == -1 && b == -1);
}
double distLP(V p) { return abs(dir().cross(p-s)/norm());}
double distSP(V p) {
if (dir().dot(p-s) < eps) return (p-s).norm();
if (dir().rev().dot(p-t) < eps) return (p-t).norm();
return distLP(p);
}
double distSS(Line l) {
if(touch(l)) return 0;
return min(min(distSP(l.s),distSP(l.t)),min(l.distSP(s),l.distSP(t)));
}
V proj(V p) {
double a = (p-s).dot(dir())/(norm()*norm());
return s + dir()*a;
}
Line mid() {
V p = (s+t)/2, q = dir();
return Line(p, p+V(q.y,-q.x));
}
V xp(Line l) {
V a = dir(), b = l.dir();
if (abs(b.cross(a)) < eps) return V(inf,inf);
return s + a*(b.cross(l.s-s)/b.cross(a));
}
};
typedef vector<V> Poly;
inline V pnxt(Poly& p, int i) { return p[(i+1)%p.size()];}
inline V ppre(Poly& p, int i) { return p[(i-1+p.size())%p.size()];}
Poly conv(Poly a) {
int n = a.size();
if (n == 1) return a;
sort(a.begin(),a.end());
Poly res(n*2);
int k = 0;
for (int i = 0; i < n; ++i){
while (k > 1 && Line(res[k-1],res[k-2]).ccw(a[i]) != 1) --k;
res[k++] = a[i];
}
int pre = k;
for (int i = n - 2; 0 <= i; --i){
while (k > pre && Line(res[k-1],res[k-2]).ccw(a[i]) != 1) --k;
res[k++] = a[i];
}
res.resize(k-1);
return res;
}
// geom
Poly a;
int main(){
a.resize(5);
rep(i,5) cin >> a[i].x >> a[i].y;
Poly c = conv(a);
puts(sz(c)==5?"YES":"NO");
return 0;
}
snuke