結果

問題 No.2602 Real Collider
ユーザー GlinTFrauleinGlinTFraulein
提出日時 2024-01-12 23:52:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 3,482 bytes
コンパイル時間 4,519 ms
コンパイル使用メモリ 255,388 KB
最終ジャッジ日時 2025-02-18 19:20:35
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 7 WA * 71
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define elif else if
#define ll long long
#define vll vector<long long>
#define vec vector
#define embk emplace_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep3(i, n, k) for (ll i = k; i < n; i++)
#define all(a) a.begin(), a.end()
#define YNeos(bool) (bool ? "Yes" : "No")
#define vllin(a, n) vll a(n); rep(i, n) cin >> a[i]
#define vchin(a, n) vec<char> a(n); rep(i, n) cin >> a[i]


using namespace std;
const ll INF = 1LL << 60;
const ll mod = 998244353;
//const ll mod = 1000000007;
const double pi = acos(-1);
const double EPS = 1 / 1000000000;  //10^-9

//#ifdef ATCODER
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
//#endif

//Prototype declaration
template <class T, class... U> void gin(T&&, U&&...);
template <typename T> vector<T> read(ll);
template <typename T> void printvec(const T&);
template <class T, class... U> void printany(T&&, U&&...);

//Main Program
int main() {
  ll q; cin >> q;
  vec<pair<double, double>> abc(3);
  rep(i, 3) {
    double x, y; gin(x, y);
    abc[i] = make_pair(x, y);
  }

  sort(all(abc));
  bool isonline = 0;
  double slope_13, itcpt_13, slope_12, itcpt_12, nor_slope_13, nor_itcpt_13, nor_slope_12, nor_itcpt_12, rad;
  pair<double, double> center;  

  if ((abc[0].first == abc[1].first && abc[0].first == abc[2].first) || (abc[0].second == abc[1].second && abc[0].second == abc[2].second)) isonline = 1;
  
  if (!isonline) {
    slope_13 = (abc[2].second - abc[0].second) / (abc[2].first - abc[0].first);
    itcpt_13 = abc[0].second - abc[0].first * slope_13;
    if (abc[1].second - (slope_13 * abc[1].first + itcpt_13) < EPS) isonline = 1;
  }

  if (!isonline) {
    slope_12 = (abc[1].second - abc[0].second) / (abc[1].first - abc[0].first);
    itcpt_12 = abc[0].second - abc[0].first * slope_13;

    nor_slope_12 = -1 / slope_12;
    nor_slope_13 = -1 / slope_13;
    nor_itcpt_12 = (abc[0].second + abc[1].second) / 2 + (abc[0].first + abc[1].first) / (slope_12 * 2);
    nor_itcpt_13 = (abc[0].second + abc[2].second) / 2 + (abc[0].first + abc[2].first) / (slope_13 * 2);

    double centerx = (nor_itcpt_12 - nor_itcpt_13) / (nor_slope_12 - nor_slope_13);
    center = make_pair(centerx, nor_slope_12 * centerx + nor_itcpt_12);
    rad = (center.first - abc[0].first) * (center.first - abc[0].first) + (center.second - abc[0].second) * (center.second - abc[0].second);
  }

  if (isonline) {
    center = make_pair((abc[0].first + abc[2].first) / 2, (abc[0].second + abc[2].second) / 2);
    rad = (center.first - abc[0].first) * (center.first - abc[0].first) + (center.second - abc[0].second) * (center.second - abc[0].second);
  }


  rep (itr, q) {
    double x, y; gin(x, y);
    ll kyori = (center.first - x) * (center.first - x) + (center.second - y) * (center.second - y);
    cout << YNeos(kyori <= rad) << endl;
  }
  




}


//Function Definition
void gin() {return;}
template <class T, class... U> void gin(T&& now,  U&&... next) {
  cin >> now;
  gin(forward<U> (next)...);
}

template <typename T> vector<T> read(ll n) {
  vector<T> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  return v;
}

template <typename T> void printvec(const T& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i];
    if (i == a.size() - 1) cout << endl;
    else cout << ' ';
  }
}

void printany() {cout << endl;}
template <class T, class... U> void printany(T&& now, U&&... next) {
  cout << now << ' ';
  printany(forward<U> (next)...);
}
0