結果

問題 No.2602 Real Collider
ユーザー 👑 hos.lyrichos.lyric
提出日時 2024-01-12 22:11:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 4,660 bytes
コンパイル時間 1,161 ms
コンパイル使用メモリ 115,440 KB
実行使用メモリ 12,700 KB
最終ジャッジ日時 2024-01-12 22:11:10
合計ジャッジ時間 6,835 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 4 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 51 ms
12,700 KB
testcase_11 AC 23 ms
7,252 KB
testcase_12 AC 28 ms
9,620 KB
testcase_13 AC 16 ms
6,812 KB
testcase_14 AC 30 ms
9,740 KB
testcase_15 AC 18 ms
6,956 KB
testcase_16 AC 27 ms
7,432 KB
testcase_17 AC 29 ms
9,616 KB
testcase_18 AC 22 ms
7,156 KB
testcase_19 AC 25 ms
7,364 KB
testcase_20 AC 32 ms
9,888 KB
testcase_21 AC 21 ms
7,096 KB
testcase_22 AC 25 ms
7,320 KB
testcase_23 AC 18 ms
6,912 KB
testcase_24 AC 23 ms
7,240 KB
testcase_25 AC 25 ms
7,316 KB
testcase_26 AC 19 ms
6,976 KB
testcase_27 AC 26 ms
7,472 KB
testcase_28 AC 28 ms
9,588 KB
testcase_29 AC 23 ms
7,292 KB
testcase_30 AC 25 ms
7,372 KB
testcase_31 AC 26 ms
7,436 KB
testcase_32 AC 24 ms
7,244 KB
testcase_33 AC 26 ms
7,440 KB
testcase_34 AC 27 ms
7,460 KB
testcase_35 AC 18 ms
6,936 KB
testcase_36 AC 18 ms
6,936 KB
testcase_37 AC 28 ms
9,604 KB
testcase_38 AC 29 ms
9,652 KB
testcase_39 AC 29 ms
9,600 KB
testcase_40 AC 16 ms
6,804 KB
testcase_41 AC 31 ms
9,792 KB
testcase_42 AC 25 ms
7,380 KB
testcase_43 AC 26 ms
7,416 KB
testcase_44 AC 32 ms
9,824 KB
testcase_45 AC 21 ms
7,152 KB
testcase_46 AC 20 ms
7,088 KB
testcase_47 AC 29 ms
9,640 KB
testcase_48 AC 23 ms
7,228 KB
testcase_49 AC 21 ms
7,068 KB
testcase_50 AC 17 ms
6,848 KB
testcase_51 AC 18 ms
6,900 KB
testcase_52 AC 15 ms
6,676 KB
testcase_53 AC 27 ms
7,456 KB
testcase_54 AC 22 ms
7,152 KB
testcase_55 AC 24 ms
7,284 KB
testcase_56 AC 23 ms
7,260 KB
testcase_57 AC 22 ms
7,184 KB
testcase_58 AC 13 ms
6,648 KB
testcase_59 AC 25 ms
7,400 KB
testcase_60 AC 24 ms
7,284 KB
testcase_61 AC 20 ms
7,012 KB
testcase_62 AC 27 ms
9,528 KB
testcase_63 AC 30 ms
9,716 KB
testcase_64 AC 34 ms
9,948 KB
testcase_65 AC 19 ms
7,000 KB
testcase_66 AC 29 ms
9,616 KB
testcase_67 AC 16 ms
6,788 KB
testcase_68 AC 18 ms
6,904 KB
testcase_69 AC 15 ms
6,676 KB
testcase_70 AC 17 ms
6,784 KB
testcase_71 AC 20 ms
6,972 KB
testcase_72 AC 26 ms
7,416 KB
testcase_73 AC 22 ms
7,188 KB
testcase_74 AC 27 ms
7,448 KB
testcase_75 AC 28 ms
9,604 KB
testcase_76 AC 25 ms
7,352 KB
testcase_77 AC 26 ms
7,416 KB
testcase_78 AC 31 ms
9,780 KB
testcase_79 AC 27 ms
9,548 KB
testcase_80 AC 30 ms
9,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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-b
  if (sig((a - b).dot(c - b)) < 0) return +2; //   a-b-c
  return 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;
}
0