結果
問題 |
No.199 星を描こう
|
ユーザー |
|
提出日時 | 2015-07-06 15:43:59 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,303 bytes |
コンパイル時間 | 910 ms |
コンパイル使用メモリ | 77,360 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-30 03:38:05 |
合計ジャッジ時間 | 1,681 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <algorithm> #include <cmath> #include <complex> #include <iostream> #include <vector> #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) using namespace std; typedef long long int ll; typedef vector<int> VI; typedef pair<int, int> PI; const double EPS=1e-9; typedef complex<double> comp; /* * Convex hull * Requirement, <vector>, <complex>, std, comp * Note: ps is modified * reference : arihon (ISBN-10: 4839931992) */ struct cmp_x { bool operator()(const comp &x, const comp &y) { return x.real() < y.real(); } }; vector<comp> convex_hull(vector<comp> &ps) { sort(ps.begin(), ps.end(), cmp_x()); const int n = ps.size(); int k = 0; vector<comp> qs(2 * n); // lower for (int i = 0; i < n; ++i) { while (k > 1 && (conj(qs[k - 1] - qs[k - 2]) * (ps[i] - qs[k - 1])).imag() <= 0) { k--; } qs[k++] = ps[i]; } // upper for (int i = n - 2, t = k; i >= 0; --i) { while (k > t && (conj(qs[k - 1] - qs[k - 2]) * (ps[i] - qs[k - 1])).imag() <= 0) { k--; } qs[k++] = ps[i]; } qs.resize(k - 1); return qs; } int main(void){ double ax = 0, ay = 0; vector<comp> ps; REP(i, 0, 5) { double p, q; cin >> p >> q; ps.push_back(comp(p, q)); } cout << (convex_hull(ps).size() == 5 ? "YES" : "NO") << endl; }