結果

問題 No.2602 Real Collider
ユーザー MisukiMisuki
提出日時 2024-01-12 21:43:31
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,139 bytes
コンパイル時間 2,552 ms
コンパイル使用メモリ 197,556 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-12 21:43:50
合計ジャッジ時間 8,797 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 2 ms
6,676 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,676 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 33 ms
6,676 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 24 ms
6,676 KB
testcase_16 AC 38 ms
6,676 KB
testcase_17 AC 42 ms
6,676 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 48 ms
6,676 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 25 ms
6,676 KB
testcase_27 WA -
testcase_28 AC 42 ms
6,676 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 38 ms
6,676 KB
testcase_32 AC 33 ms
6,676 KB
testcase_33 AC 38 ms
6,676 KB
testcase_34 AC 39 ms
6,676 KB
testcase_35 AC 24 ms
6,676 KB
testcase_36 AC 24 ms
6,676 KB
testcase_37 AC 42 ms
6,676 KB
testcase_38 AC 42 ms
6,676 KB
testcase_39 AC 41 ms
6,676 KB
testcase_40 AC 20 ms
6,676 KB
testcase_41 AC 47 ms
6,676 KB
testcase_42 AC 37 ms
6,676 KB
testcase_43 AC 38 ms
6,676 KB
testcase_44 AC 48 ms
6,676 KB
testcase_45 AC 30 ms
6,676 KB
testcase_46 AC 29 ms
6,676 KB
testcase_47 AC 44 ms
6,676 KB
testcase_48 AC 32 ms
6,676 KB
testcase_49 AC 27 ms
6,676 KB
testcase_50 AC 22 ms
6,676 KB
testcase_51 AC 23 ms
6,676 KB
testcase_52 AC 17 ms
6,676 KB
testcase_53 AC 39 ms
6,676 KB
testcase_54 AC 30 ms
6,676 KB
testcase_55 AC 34 ms
6,676 KB
testcase_56 AC 33 ms
6,676 KB
testcase_57 AC 30 ms
6,676 KB
testcase_58 AC 13 ms
6,676 KB
testcase_59 AC 37 ms
6,676 KB
testcase_60 AC 35 ms
6,676 KB
testcase_61 AC 26 ms
6,676 KB
testcase_62 AC 40 ms
6,676 KB
testcase_63 AC 44 ms
6,676 KB
testcase_64 AC 51 ms
6,676 KB
testcase_65 AC 27 ms
6,676 KB
testcase_66 AC 42 ms
6,676 KB
testcase_67 AC 20 ms
6,676 KB
testcase_68 AC 23 ms
6,676 KB
testcase_69 AC 17 ms
6,676 KB
testcase_70 AC 20 ms
6,676 KB
testcase_71 AC 25 ms
6,676 KB
testcase_72 AC 38 ms
6,676 KB
testcase_73 AC 30 ms
6,676 KB
testcase_74 AC 38 ms
6,676 KB
testcase_75 AC 41 ms
6,676 KB
testcase_76 AC 36 ms
6,676 KB
testcase_77 AC 38 ms
6,676 KB
testcase_78 AC 46 ms
6,676 KB
testcase_79 AC 40 ms
6,676 KB
testcase_80 AC 46 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O2")
#include <algorithm>
#include <array>
#include <bit>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfenv>
#include <cfloat>
#include <chrono>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <compare>
#include <complex>
#include <concepts>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numbers>
#include <numeric>
#include <ostream>
#include <queue>
#include <random>
#include <ranges>
#include <set>
#include <span>
#include <sstream>
#include <stack>
#include <streambuf>
#include <string>
#include <tuple>
#include <type_traits>
#include <variant>

#define int ll
#define INT128_MAX (__int128)(((unsigned __int128) 1 << ((sizeof(__int128) * __CHAR_BIT__) - 1)) - 1)
#define INT128_MIN (-INT128_MAX - 1)

#ifdef DEBUG
#define dbg(x) cout << (#x) << " = " << x << '\n'
#else
#define dbg(x)
#endif

namespace R = std::ranges;
namespace V = std::views;

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldb = long double;
#define double ldb

template<class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N> &arr) {
  for(const T &X : arr)
    os << X << ' ';
  return os;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T> &vec) {
  for(const T &X : vec)
    os << X << ' ';
  return os;
}
template<class T>
ostream& operator<<(ostream& os, const set<T> &s) {
  for(const T &x : s)
    os << x << ' ';
  return os;
}

/**
 * template name: geometryBasic
 */

template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
	friend ostream& operator<<(ostream& os, P p) {
		return os << "(" << p.x << "," << p.y << ")"; }
};

/**
 * template name: geometryLine
 */

template<class P> bool onSegment(P s, P e, P p) {
	return p.cross(s, e) == 0 && (s - p).dot(e - p) <= 0;
}

/**
 * template name: geometry circle
 */

using P = Point<double>;

double ccRadius(const P& A, const P& B, const P& C) {
	return (B-A).dist()*(C-B).dist()*(A-C).dist()/
			abs((B-A).cross(C-A))/2;
}
P ccCenter(const P& A, const P& B, const P& C) {
	P b = C-A, c = B-A;
	return A + (b*c.dist2()-c*b.dist2()).perp()/b.cross(c)/2;
}

const double eps = 1e-9;

signed main() {
  ios::sync_with_stdio(false), cin.tie(NULL);

  int q; cin >> q;
  array<P, 3> pts;
  for(auto &x : pts)
    cin >> x.x >> x.y;
  double r;
  P center;
  if (onSegment(pts[0], pts[2], pts[1])) {
    r = (pts[2] - pts[0]).dist() / 2;
    center = (pts[2] + pts[0]) / 2;
  } else {
    r = ccRadius(pts[0], pts[1], pts[2]);
    center = ccCenter(pts[0], pts[1], pts[2]);
  }
  while(q--) {
    P pt; cin >> pt.x >> pt.y;
    if ((center - pt).dist() <= r + eps)
      cout << "Yes\n";
    else
      cout << "No\n";
  }

  dbg(center);
  dbg(r);

  return 0;
}
0