結果

問題 No.199 星を描こう
ユーザー kyuridenamidakyuridenamida
提出日時 2016-08-25 16:34:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 3,280 bytes
コンパイル時間 1,334 ms
コンパイル使用メモリ 102,192 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 18:47:27
合計ジャッジ時間 2,263 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
}
0