結果
| 問題 |
No.199 星を描こう
|
| コンテスト | |
| ユーザー |
anta
|
| 提出日時 | 2015-04-28 23:39:33 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,596 bytes |
| コンパイル時間 | 737 ms |
| コンパイル使用メモリ | 86,760 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-05 05:08:51 |
| 合計ジャッジ時間 | 1,577 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 WA * 1 |
ソースコード
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
struct P {
typedef int T; typedef ll T2; //T2は{a*b | a:T, b:T}を含むタイプ
T x, y;
P(T x_, T y_): x(x_), y(y_) {}
P(): x(0), y(0) {}
};
inline bool operator==(const P& a, const P& b) { return a.x == b.x && a.y == b.y; }
inline bool operator<(const P& a, const P& b) { return a.x < b.x || (a.x == b.x && a.y < b.y); }
inline P operator+(const P& a, const P& b) { return P(a.x+b.x, a.y+b.y); }
inline P operator-(const P& a, const P& b) { return P(a.x-b.x, a.y-b.y); }
inline P operator-=(P& a, const P& b) { a.x -= b.x, a.y -= b.y ; return a; }
inline P::T2 cross(const P& a, const P& b) { return (P::T2)a.x*b.y - (P::T2)a.y*b.x; }
inline P::T2 dot(const P& a, const P& b) { return (P::T2)a.x*b.x + (P::T2)a.y*b.y; }
inline P::T2 norm(const P& a) { return (P::T2)a.x*a.x + (P::T2)a.y*a.y; }
ostream& operator<<(ostream& out, const P& x) { out << "(" << x.x << ", " << x.y << ")"; return out; }
struct L {
P a, b;
L(const P &a_, const P &b_): a(a_), b(b_) {}
const P& operator[](size_t i) const { return i ? b : a; }
};
inline int ccw(const P& a, const P& b, const P& c) {
int ax = b.x - a.x, ay = b.y - a.y, bx = c.x - a.x, by = c.y - a.y;
P::T2 t = (P::T2)ax*by - (P::T2)ay*bx;
if (t > 0) return 1;
if (t < 0) return -1;
if((P::T2)ax*bx + (P::T2)ay*by < 0) return +2;
if((P::T2)ax*ax + (P::T2)ay*ay < (P::T2)bx*bx + (P::T2)by*by) return -2;
return 0;
}
int intersectSS(const L &s, const L &t) {
assert(!(s.a == s.b || t.a == t.b));
int a = ccw(s.a,s.b,t.a), b = ccw(s.a,s.b,t.b), c = ccw(t.a,t.b,s.a), d = ccw(t.a,t.b,s.b);
int x = a * b, y = c * d;
if(x == -1 && y == -1) return 0; //cross
else if(
((abs(b) == 1 || b == -2) && s.b == t.a) ||
((abs(b) == 1 || b == 2) && s.a == t.a) ||
((abs(a) == 1 || a == -2) && s.b == t.b) ||
((abs(a) == 1 || a == 2) && s.a == t.b)
) return 2; // point overlap (真ん中と端を共有する)
else if(
(x == 0 && (abs(a) + abs(b) == 1)) ||
(y == 0 && (abs(c) + abs(d) == 1))
) return 3; // point overlap (端点のみを共有する)
else if(x <= 0 && y <= 0) return 0; //segment overlap
else return 1;
}
int main() {
P ps[5];
rep(k, 5) cin >> ps[k].x >> ps[k].y;
sort(ps, ps + 5);
bool ans = false;
do {
bool ok = true;
rep(k, 5) {
L s(ps[k], ps[(k+2)%5]);
L t(ps[(k+1)%5], ps[(k+3)%5]);
ok &= intersectSS(s, t) == 0;
}
ans |= ok;
}while(next_permutation(ps, ps + 5));
puts(ans ? "YES" : "NO");
return 0;
}
anta