結果
| 問題 |
No.199 星を描こう
|
| コンテスト | |
| ユーザー |
kyuridenamida
|
| 提出日時 | 2016-08-25 16:34:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 3,280 bytes |
| コンパイル時間 | 1,367 ms |
| コンパイル使用メモリ | 105,828 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-30 03:52:10 |
| 合計ジャッジ時間 | 2,637 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <unordered_set>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <fstream>
#include <sstream>
#include <complex>
#include <bitset>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rev(i,n) for(int i=(n)-1;(i)>=0;(i)--)
#define all(a) (a).begin(),(a).end()
#define pb(a) push_back(a)
#define bitcount(b) __builtin_popcount(b)
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false; for(int i=2;i*i<=n;i++)if(n%i==0)return false; return true;}
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
bool operator < (const P& a, const P& b) {
if( abs(a-b) < EPS ) return false;
return abs(real(a)-real(b))>EPS ? real(a) < real(b) : imag(a) < imag(b);
}
}
double cross(const P& a, const P& b) {
return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
return real(conj(a)*b);
}
struct L : public vector<P> {
L(){}
L(const P &a, const P &b) {
push_back(a); push_back(b);
}
};
int ccw(P a, P b, P c) {
b -= a; c -= a;
if (cross(b, c) > 0) return +1; // counter clockwise
if (cross(b, c) < 0) return -1; // clockwise
if (dot(b, c) < 0) return +2; // c--a--b on line
if (norm(b) < norm(c)) return -2; // a--b--c on line
return 0;
}
typedef vector<P> G;
bool intersectSS(const L &s, const L &t) {
return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
P crosspoint(const L &l, const L &m) {
double A = cross(l[1] - l[0], m[1] - m[0]);
double B = cross(l[1] - l[0], l[1] - m[0]);
if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
return m[0] + B / A * (m[1] - m[0]);
}
bool reallyIntersect(const L &s, const L &t) {
if( intersectSS(s,t) == false ) return false;
P cp = crosspoint(s,t);
for(int i = 0 ; i < 2 ; i++){
if( abs(cp-s[i]) <= EPS ) return false;
if( abs(cp-t[i]) <= EPS ) return false;
}
return true;
}
int main(){
P p[5];
for(int i = 0 ; i < 5 ; i++){
double x,y;
cin >> x >> y;
p[i] = P(x,y);
}
sort(p,p+5);
do{
L l[10];
for(int i = 0 ; i < 10 ; i++)
l[i] = L(p[i%5],p[(i+1)%5]);
int f = -1;
for(int i = 0 ; i < 5 ; i++){
if( reallyIntersect(l[i],l[i+1]) == false ){} else { f = 0; }
if( reallyIntersect(l[i],l[i+2]) == true ){ } else { f = 1; }
if( reallyIntersect(l[i],l[i+3]) == true ){} else { f = 2; }
if( reallyIntersect(l[i],l[i+4]) == false ){} else { f = 3; }
}
if( f == -1 ){
//cout << p[0] << "->" << p[1] << "->" << p[2] << "->" << p[3] << "->" << p[4] << endl;
cout << "YES" << endl;
return 0;
}
}while(next_permutation(p,p+5));
cout << "NO" << endl;
}
kyuridenamida