結果
| 問題 | 
                            No.199 星を描こう
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2015-04-29 01:11:38 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 1,676 bytes | 
| コンパイル時間 | 778 ms | 
| コンパイル使用メモリ | 64,692 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-30 03:31:17 | 
| 合計ジャッジ時間 | 1,663 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 25 | 
ソースコード
#include<iostream>
#include<complex>
#include<cstdlib>
#define EPS  (1.0e-7)
#define GT(x,y) ((x)>=(y)+EPS)
#define LT(x,y) ((x)<=(y)-EPS)
using namespace std;
typedef complex<double> Point;
double dot(Point a, Point b){
  return real(conj(a)*b);
}
double cross(Point a, Point b){
  return imag(conj(a)*b);
}
int ccw(Point a, Point b, Point c){
  Point d1 = b-a, d2 = c-a;
  if(GT(cross(d1,d2),0)) return 1;
  if(LT(cross(d1,d2),0)) return -1;
  if(LT(dot(d1,d2),0)) return -2;      // b - a - c
  if(LT(norm(d1),norm(d2))) return 2;  // a - b - c
  return 0;                            // a - c - b
}
Point pt[5];
void read() {
    for (int i = 0; i < 5; ++i) {
        double x, y;
        cin >> x >> y;
        pt[i] = Point(x, y);
    }
}
bool contain(Point a, Point b, Point c, Point p) {
    if (abs(ccw(a, b, p)) == 1 &&
        ccw(a, b, p) == ccw(b, c, p) &&
        ccw(b, c, p) == ccw(c, a, p))
        return true;
    
    if (abs(ccw(a, b, p)) == 2 || ccw(a, b, p) == 0 ||
        abs(ccw(b, c, p)) == 2 || ccw(b, c, p) == 0 ||
        abs(ccw(c, a, p)) == 2 || ccw(c, a, p) == 0)
        return true;
    return false;
}
void work() {
    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 l = 0; l < 5; ++l) {
                    if (i == l || j == l || k == l)
                        continue;
                    if (contain(pt[i], pt[j], pt[k], pt[l])) {
                        cout << "NO" << endl;
                        return;
                    }
                }
    cout << "YES" << endl;
}
int main() {
    read();
    work();
    return 0;
}