結果

問題 No.2602 Real Collider
ユーザー KudeKude
提出日時 2024-01-12 22:01:40
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 5,136 bytes
コンパイル時間 4,473 ms
コンパイル使用メモリ 272,248 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-12 22:02:21
合計ジャッジ時間 9,031 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 WA -
testcase_04 AC 3 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 WA -
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 21 ms
6,676 KB
testcase_13 AC 11 ms
6,676 KB
testcase_14 AC 22 ms
6,676 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 15 ms
6,676 KB
testcase_19 AC 20 ms
6,676 KB
testcase_20 WA -
testcase_21 AC 14 ms
6,676 KB
testcase_22 AC 17 ms
6,676 KB
testcase_23 AC 12 ms
6,676 KB
testcase_24 AC 17 ms
6,676 KB
testcase_25 AC 17 ms
6,676 KB
testcase_26 WA -
testcase_27 AC 19 ms
6,676 KB
testcase_28 WA -
testcase_29 AC 17 ms
6,676 KB
testcase_30 AC 18 ms
6,676 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;

struct Vec {
  using etype = int;  // type of elements
  using ptype = int;  // type of product results
  etype x = 0, y = 0;
  constexpr Vec operator-() const { return {-x, -y}; }
  friend constexpr Vec operator+(const Vec& a, const Vec& b) { return {a.x + b.x, a.y + b.y}; }
  friend constexpr Vec operator-(const Vec& a, const Vec& b) { return {a.x - b.x, a.y - b.y}; }
  friend constexpr ptype operator*(const Vec& a, const Vec& b) { return (ptype)a.x * b.y - (ptype)a.y * b.x; }
  template <class T, enable_if_t<is_integral_v<T>>* = nullptr>
  friend constexpr Vec operator*(T c, const Vec& a) { return {c * a.x, c * a.y}; }
  template <class T, enable_if_t<is_integral_v<T>>* = nullptr>
  friend constexpr Vec operator*(const Vec& a, T c) { return c * a; }
  template <class T, enable_if_t<is_integral_v<T>>* = nullptr>
  friend constexpr Vec operator/(const Vec& a, T c) { return {a.x / c, a.y / c}; }
  Vec& operator+=(const Vec& a) { x += a.x; y += a.y; return *this; }
  Vec& operator-=(const Vec& a) { x -= a.x; y -= a.y; return *this; }
  template <class T, enable_if_t<is_integral_v<T>>* = nullptr>
  Vec& operator*=(T c) { x *= c; y *= c; return *this; }
  friend constexpr bool operator==(const Vec& a, const Vec& b) { return a.x == b.x && a.y == b.y; }
  friend constexpr bool operator!=(const Vec& a, const Vec& b) { return !(a == b); }
  constexpr int quadrant() const { return y > 0 ? (x > 0 ? 0 : 1) : y < 0 ? (x < 0 ? 2 : 3) : (x > 0 ? 0 : x < 0 ? 2 : -1); }
  friend constexpr bool operator<(const Vec& a, const Vec& b) {
    int qa = a.quadrant(), qb = b.quadrant();
    if (qa != qb) return qa < qb;
    ptype p1 = (ptype)a.x * b.y, p2 = (ptype)a.y * b.x;
    return p1 > p2 || (p1 == p2 && (a.x != 0 ? abs(a.x) < abs(b.x) : abs(a.y) < abs(b.y)));
  }
  friend constexpr bool operator>(const Vec& a, const Vec& b) { return b < a; }
  friend constexpr bool operator<=(const Vec& a, const Vec& b) { return !(b < a); }
  friend constexpr bool operator>=(const Vec& a, const Vec& b) { return !(a < b); }
  constexpr int ccw(const Vec& u, const Vec& v) const { ptype p = (u - *this) * (v - *this); return p > 0 ? 1 : p < 0 ? -1 : 0; }
  static constexpr bool intersects(const Vec& a, const Vec& b, const Vec& c, const Vec& d) { return a.ccw(b, c) * a.ccw(b, d) <= 0 && c.ccw(d, a) * c.ccw(d, b) <= 0; }
  constexpr bool parallel_to(const Vec& a) const { return (ptype)x * a.y == (ptype)y * a.x; }
  constexpr ptype dot(const Vec& a) const { return (ptype)x * a.x + (ptype)y * a.y; }
  constexpr ptype norm2() const { return (ptype)x * x + (ptype)y * y; }
  constexpr bool is_zero() const { return x == 0 && y == 0; }
  constexpr Vec normalize() const {
    if (x == 0) return Vec{0, (y == 0 ? 0 : 1)};
    etype g = gcd(x, y);
    return *this / (x > 0 ? g : -g);
  }
  constexpr Vec rot90() const { return {-y, x}; }
  // exclusive
  constexpr bool in_between(const Vec& a, const Vec& b) const {
    Vec x = a - *this, y = b - *this;
    return x.parallel_to(y) && x.dot(y) < 0;
  }
  friend std::ostream& operator<< (std::ostream& os, const Vec& t) { return os << t.x << ' ' << t.y; }
  friend std::istream& operator>> (std::istream& os, Vec& t) { return os >> t.x >> t.y; }
};

} int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int q;
  cin >> q;
  Vec a, b, c;
  cin >> a >> b >> c;
  a *= 2, b *= 2, c *= 2;
  rep(_, 3) {
    Vec o = (a + b) / 2;
    ll r2 = (a - o).norm2();
    if ((c - o).norm2() > r2) {
      swap(a, b);
      swap(b, c);
      continue;
    }
    rep(_, q) {
      Vec v;
      cin >> v;
      v *= 2;
      bool ans = (v - o).norm2() <= r2;
      cout << (ans ? "Yes\n" : "No\n");
    }
    return 0;
  }
  auto cs = [](Vec a, Vec b, Vec c) {
    int p = b.norm2() + c.norm2() - a.norm2();
    ll p2 = (ll)p * p;
    ll q2 = (ll)b.norm2() * c.norm2();
    return pair(p2, q2);
  };
  rep(_, q) {
    Vec v;
    cin >> v;
    v *= 2;
    bool ans = false;
    auto [pa, qa] = cs(b - a, a - c, b - c);
    auto [px, qx] = cs(b - a, a - v, b - v);
    auto ca = __int128(pa) * qx;
    auto cx = __int128(px) * qa;
    // cout << a << endl;
    // cout << b << endl;
    // cout << c << endl;
    // cout << pa << ' ' << qa << ' ' << px << ' ' << qx << endl;
    // exit(0);
    if (((b - a) * (c - a) >= 0) == ((b - a) * (v - a) >= 0)) {
      ans = cx <= ca;
    } else {
      ans = cx <= -ca;
    }
    cout << (ans ? "Yes\n" : "No\n");
  }
}
0