結果
問題 |
No.2602 Real Collider
|
ユーザー |
👑 |
提出日時 | 2024-01-12 22:03:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,562 bytes |
コンパイル時間 | 1,018 ms |
コンパイル使用メモリ | 113,292 KB |
実行使用メモリ | 9,468 KB |
最終ジャッジ日時 | 2024-09-27 22:18:19 |
合計ジャッジ時間 | 6,227 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 74 WA * 4 |
ソースコード
#include <cassert> #include <cmath> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using Int = long long; template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; } template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; } template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; } template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; } #define COLOR(s) ("\x1b[" s "m") using Double = long double; const Double EPS = 1e-12L; const Double INF = 1e+10L; const Double PI = acos(-1.0L); inline int sig(Double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; } inline Double sq(Double r) { return r * r; } struct Pt { Double x, y; Pt() {} Pt(Double x_, Double y_) : x(x_), y(y_) {} Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); } Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); } Pt operator*(const Pt &a) const { return Pt(x * a.x - y * a.y, x * a.y + y * a.x); } Pt operator/(const Pt &a) const { const Double d2 = a.abs2(); return Pt((x * a.x + y * a.y) / d2, (y * a.x - x * a.y) / d2); } Pt operator+() const { return Pt(+x, +y); } Pt operator-() const { return Pt(-x, -y); } Pt operator*(const Double &k) const { return Pt(x * k, y * k); } Pt operator/(const Double &k) const { return Pt(x / k, y / k); } friend Pt operator*(const Double &k, const Pt &a) { return Pt(k * a.x, k * a.y); } Pt &operator+=(const Pt &a) { x += a.x; y += a.y; return *this; } Pt &operator-=(const Pt &a) { x -= a.x; y -= a.y; return *this; } Pt &operator*=(const Pt &a) { return *this = *this * a; } Pt &operator/=(const Pt &a) { return *this = *this / a; } Pt &operator*=(const Double &k) { x *= k; y *= k; return *this; } Pt &operator/=(const Double &k) { x /= k; y /= k; return *this; } Double abs() const { return sqrt(x * x + y * y); } Double abs2() const { return x * x + y * y; } Double arg() const { return atan2(y, x); } Double dot(const Pt &a) const { return x * a.x + y * a.y; } Double det(const Pt &a) const { return x * a.y - y * a.x; } friend ostream &operator<<(ostream &os, const Pt &a) { os << "(" << a.x << ", " << a.y << ")"; return os; } }; inline Double tri(const Pt &a, const Pt &b, const Pt &c) { return (b - a).det(c - a); } int iSP(const Pt &a, const Pt &b, const Pt &c) { int s = sig((b - a).det(c - a)); if (s != 0) return s; if (sig((b - a).dot(c - a)) < 0) return -2; // c-a-b if (sig((a - b).dot(c - b)) < 0) return +2; // a-b-c return 0; } Pt circumcenter(const Pt &a, const Pt &b, const Pt &c) { const Pt bc = c - b, ca = a - c, ab = b - a; return (b + c - bc * Pt(0, 1) * ca.dot(ab) / ca.det(ab)) / 2; } int Q; vector<Pt> P; int main() { for (; ~scanf("%d", &Q); ) { P.resize(3 + Q); for (int i = 0; i < 3 + Q; ++i) { int x, y; scanf("%d%d", &x, &y); P[i] = Pt(x, y); } if ((P[1] - P[0]).det(P[2] - P[0]) < 0) { swap(P[1], P[2]); } Pt cen; Double rad; for (int i = 0; i < 3; ++i) { const Pt &p0 = P[i]; const Pt &p1 = P[(i + 1) % 3]; const Pt &p2 = P[(i + 2) % 3]; if (iSP(p1, p2, p0) == 0) { cen = (p1 + p2) / 2; rad = (p1 - cen).abs(); goto don; } } for (int i = 0; i < 3; ++i) { const Pt &p0 = P[i]; const Pt &p1 = P[(i + 1) % 3]; const Pt &p2 = P[(i + 2) % 3]; if (sig((p1 - p0).dot(p2 - p0)) < 0) { cen = (p1 + p2) / 2; rad = (p1 - cen).abs(); goto don; } } cen = circumcenter(P[0], P[1], P[2]); rad = (P[0] - cen).abs(); don:{} for (int i = 3; i < 3 + Q; ++i) { const Double d = (P[i] - cen).abs(); puts((sig(d - rad) <= 0) ? "Yes" : "No"); } } return 0; }