結果
問題 | No.2602 Real Collider |
ユーザー |
👑 |
提出日時 | 2024-01-12 22:11:03 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 4,660 bytes |
コンパイル時間 | 1,241 ms |
コンパイル使用メモリ | 114,928 KB |
実行使用メモリ | 12,672 KB |
最終ジャッジ日時 | 2024-09-27 22:37:37 |
合計ジャッジ時間 | 6,561 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 78 |
ソースコード
#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")inline int sig(Int r) { return (r < 0) ? -1 : (r > 0) ? +1 : 0; }inline Int sq(Int r) { return r * r; }struct Pt {Int x, y;Pt() : x(0), y(0) {}Pt(Int x_, Int 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 { return Pt(+x, +y); }Pt operator-() const { return Pt(-x, -y); }Pt operator*(const Int &k) const { return Pt(x * k, y * k); }Pt operator/(const Int &k) const { return Pt(x / k, y / k); }friend Pt operator*(const Int &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 Int &k) { x *= k; y *= k; return *this; }Int abs2() const { return x * x + y * y; }Int dot(const Pt &a) const { return x * a.x + y * a.y; }Int det(const Pt &a) const { return x * a.y - y * a.x; }bool operator==(const Pt &a) const { return (x == a.x && y == a.y); }bool operator<(const Pt &a) const { return ((x != a.x) ? (x < a.x) : (y < a.y)); }friend ostream &operator<<(ostream &os, const Pt &a) { os << "(" << a.x << ", " << a.y << ")"; return os; }};inline Int tri(const Pt &a, const Pt &b, const Pt &c) { return (b - a).det(c - a); }// Watch out for the case a == b.int iSP(const Pt &a, const Pt &b, const Pt &c) {int s = sig((b - a).det(c - a));if (s) return s;if (sig((b - a).dot(c - a)) < 0) return -2; // c-a-bif (sig((a - b).dot(c - b)) < 0) return +2; // a-b-creturn 0;}int Q;vector<Pt> P;Int mat[200'010][4];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(2 * x, 2 * y);}cerr<<"P = "<<P<<endl;if ((P[1] - P[0]).det(P[2] - P[0]) < 0) {swap(P[1], P[2]);}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) {const Pt cen = (p1 + p2) / 2;P[i] = cen + (p2 - cen) * Pt(0, 1);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) {const Pt cen = (p1 + p2) / 2;P[i] = cen + (p2 - cen) * Pt(0, 1);goto don;}}don:{}cerr<<"P = "<<P<<endl;for (int i = 0; i < 3 + Q; ++i) {mat[i][0] = P[i].abs2();mat[i][1] = P[i].x;mat[i][2] = P[i].y;mat[i][3] = 1;}Int coef[4] = {};{int perm[4] = {0, 1, 2, 3};do {Int prod = 1;for (int i = 0; i < 4; ++i) for (int j = i + 1; j < 4; ++j) if (perm[i] > perm[j]) prod = -prod;for (int i = 1; i < 4; ++i) prod *= mat[i - 1][perm[i]];coef[perm[0]] += prod;} while (next_permutation(perm, perm + 4));}for (int i = 3; i < 3 + Q; ++i) {Int ans = 0;for (int j = 0; j < 4; ++j) ans += coef[j] * mat[i][j];// cerr<<"ans = "<<ans<<endl;puts((ans <= 0) ? "Yes" : "No");}}return 0;}