結果

問題 No.199 星を描こう
ユーザー okaduki
提出日時 2015-04-29 00:26:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 784 bytes
コンパイル時間 655 ms
コンパイル使用メモリ 61,656 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-30 03:24:14
合計ジャッジ時間 1,609 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

struct P{
  int x, y;
  P operator-(const P& p){
	P q;
	q.x = x - p.x, q.y = y - p.y;
	return q;
  }
};

int cross(P p1, P p2){
  return p1.x*p2.y - p1.y*p2.x;
}

P ps[5];
int main(){
  for(int i=0;i<5;++i)
	cin >> ps[i].x >> ps[i].y;

  vector<bool> ok(5, true);
  for(int i=0;i<5;++i)
	for(int j=i+1;j<5;++j)
	  for(int k=j+1;k<5;++k){
		for(int h=0;h<5;++h){
		  if(i == h || j == h || k == h) continue;
		  int c1 = cross(ps[j]-ps[i],ps[h]-ps[j]);
		  int c2 = cross(ps[k]-ps[j],ps[h]-ps[k]);
		  int c3 = cross(ps[i]-ps[k],ps[h]-ps[i]);
		  if((c1<=0&&c2<=0&&c3<=0)||(c1>=0&&c2>=0&&c3>=0))
			ok[h] = false;
		}
	  }
  int cnt = 0;
  for(int i=0;i<5;++i) if(ok[i]) ++cnt;
  cout << (cnt == 5? "YES": "NO") << endl;

}
0