結果
| 問題 | No.199 星を描こう |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2016-03-27 02:40:16 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 3,162 bytes |
| コンパイル時間 | 786 ms |
| コンパイル使用メモリ | 86,216 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-30 03:47:38 |
| 合計ジャッジ時間 | 1,782 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 199.cc: No.199 星を描こう - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int N = 5;
/* typedef */
template <typename T>
struct Pt {
T x, y;
Pt() {}
Pt(T _x, T _y) : x(_x), y(_y) {}
Pt(const Pt& pt) : x(pt.x), y(pt.y) {}
bool operator==(const Pt pt) const { return x == pt.x && y == pt.y; }
Pt<T> operator+(const Pt pt) const { return Pt<T>(x + pt.x, y + pt.y); }
Pt<T> operator-() const { return Pt<T>(-x, -y); }
Pt<T> operator-(const Pt pt) const { return Pt<T>(x - pt.x, y - pt.y); }
Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
T dot(Pt v) const { return x * v.x + y * v.y; }
T cross(Pt v) const { return x * v.y - y * v.x; }
Pt<T> mid(const Pt pt) { return Pt<T>((x + pt.x) / 2, (y + pt.y) / 2); }
T d2() { return x * x + y * y; }
double d() { return sqrt(d2()); }
Pt<T> rot(double th) {
double c = cos(th), s = sin(th);
return Pt<T>(c * x - s * y, s * x + c * y);
}
Pt<T> rot90() { return Pt<T>(-y, x); }
bool operator<(const Pt& pt) const {
return x < pt.x || (x == pt.x && y < pt.y);
}
void print(string format) {
printf(("(" + format + ", " + format + ")\n").c_str(), x, y);
}
void print() { print("%.6lf"); }
};
typedef Pt<double> pt;
struct CL {
pt p;
double t0, t1;
CL() {}
CL(const pt& _p, double _t0, double _t1) : p(_p), t0(_t0), t1(_t1) {}
};
/* global variables */
pt pts[N];
bool cm[N][N][N][N];
int pmis[N];
/* subroutines */
bool cross_lines(const pt& ap, const pt av, const pt& bp, const pt bv) {
double op01 = av.cross(bv);
if (op01 == 0.0) return false;
pt v = bp - ap;
double op0 = v.cross(av);
double op1 = v.cross(bv);
double t0 = op1 / op01;
double t1 = op0 / op01;
CL cl;
cl.p = bv * t1 + bp;
cl.t0 = t0;
cl.t1 = t1;
return (0.0 < cl.t0 && cl.t0 < 1.0 && 0.0 < cl.t1 && cl.t1 < 1.0);
}
/* main */
int main() {
for (int i = 0; i < N; i++) cin >> pts[i].x >> pts[i].y;
for (int i = 0; i < N; i++)
for (int j = i + 1; j < N; j++) {
pt vij = pts[j] - pts[i];
for (int k = 0; k < N; k++)
if (k != i && k != j)
for (int l = k + 1; l < N; l++)
if (l != i && l != j) {
pt vkl = pts[l] - pts[k];
if (cross_lines(pts[i], vij, pts[k], vkl))
cm[i][j][k][l] = cm[j][i][k][l] =
cm[i][j][l][k] = cm[j][i][l][k] = true;
}
}
for (int i = 0; i < N; i++) pmis[i] = i;
do {
bool ok = true;
int is[N];
for (int i = 0; ok && i < N; i++) {
for (int j = 0; j < N; j++) is[j] = pmis[(i + j) % N];
if (! cm[is[0]][is[1]][is[2]][is[3]] ||
! cm[is[0]][is[1]][is[3]][is[4]]) ok = false;
}
if (ok) {
puts("YES");
return 0;
}
} while (next_permutation(pmis, pmis + N));
puts("NO");
return 0;
}
tnakao0123