結果
問題 | No.2602 Real Collider |
ユーザー | maeshun |
提出日時 | 2024-01-13 14:39:30 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 388 ms / 2,000 ms |
コード長 | 5,489 bytes |
コンパイル時間 | 4,583 ms |
コンパイル使用メモリ | 267,508 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-28 01:29:42 |
合計ジャッジ時間 | 19,235 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 388 ms
5,376 KB |
testcase_11 | AC | 143 ms
5,376 KB |
testcase_12 | AC | 182 ms
5,376 KB |
testcase_13 | AC | 88 ms
5,376 KB |
testcase_14 | AC | 191 ms
5,376 KB |
testcase_15 | AC | 102 ms
5,376 KB |
testcase_16 | AC | 163 ms
5,376 KB |
testcase_17 | AC | 184 ms
5,376 KB |
testcase_18 | AC | 128 ms
5,376 KB |
testcase_19 | AC | 157 ms
5,376 KB |
testcase_20 | AC | 212 ms
5,376 KB |
testcase_21 | AC | 124 ms
5,376 KB |
testcase_22 | AC | 149 ms
5,376 KB |
testcase_23 | AC | 97 ms
5,376 KB |
testcase_24 | AC | 140 ms
5,376 KB |
testcase_25 | AC | 149 ms
5,376 KB |
testcase_26 | AC | 108 ms
5,376 KB |
testcase_27 | AC | 169 ms
5,376 KB |
testcase_28 | AC | 176 ms
5,376 KB |
testcase_29 | AC | 147 ms
5,376 KB |
testcase_30 | AC | 159 ms
5,376 KB |
testcase_31 | AC | 162 ms
5,376 KB |
testcase_32 | AC | 140 ms
5,376 KB |
testcase_33 | AC | 165 ms
5,376 KB |
testcase_34 | AC | 167 ms
5,376 KB |
testcase_35 | AC | 103 ms
5,376 KB |
testcase_36 | AC | 105 ms
5,376 KB |
testcase_37 | AC | 178 ms
5,376 KB |
testcase_38 | AC | 184 ms
5,376 KB |
testcase_39 | AC | 184 ms
5,376 KB |
testcase_40 | AC | 88 ms
5,376 KB |
testcase_41 | AC | 208 ms
5,376 KB |
testcase_42 | AC | 164 ms
5,376 KB |
testcase_43 | AC | 163 ms
5,376 KB |
testcase_44 | AC | 207 ms
5,376 KB |
testcase_45 | AC | 128 ms
5,376 KB |
testcase_46 | AC | 122 ms
5,376 KB |
testcase_47 | AC | 186 ms
5,376 KB |
testcase_48 | AC | 135 ms
5,376 KB |
testcase_49 | AC | 116 ms
5,376 KB |
testcase_50 | AC | 92 ms
5,376 KB |
testcase_51 | AC | 98 ms
5,376 KB |
testcase_52 | AC | 70 ms
5,376 KB |
testcase_53 | AC | 170 ms
5,376 KB |
testcase_54 | AC | 131 ms
5,376 KB |
testcase_55 | AC | 145 ms
5,376 KB |
testcase_56 | AC | 145 ms
5,376 KB |
testcase_57 | AC | 137 ms
5,376 KB |
testcase_58 | AC | 53 ms
5,376 KB |
testcase_59 | AC | 162 ms
5,376 KB |
testcase_60 | AC | 149 ms
5,376 KB |
testcase_61 | AC | 112 ms
5,376 KB |
testcase_62 | AC | 172 ms
5,376 KB |
testcase_63 | AC | 192 ms
5,376 KB |
testcase_64 | AC | 218 ms
5,376 KB |
testcase_65 | AC | 113 ms
5,376 KB |
testcase_66 | AC | 179 ms
5,376 KB |
testcase_67 | AC | 84 ms
5,376 KB |
testcase_68 | AC | 101 ms
5,376 KB |
testcase_69 | AC | 70 ms
5,376 KB |
testcase_70 | AC | 84 ms
5,376 KB |
testcase_71 | AC | 105 ms
5,376 KB |
testcase_72 | AC | 165 ms
5,376 KB |
testcase_73 | AC | 134 ms
5,376 KB |
testcase_74 | AC | 163 ms
5,376 KB |
testcase_75 | AC | 179 ms
5,376 KB |
testcase_76 | AC | 154 ms
5,376 KB |
testcase_77 | AC | 167 ms
5,376 KB |
testcase_78 | AC | 200 ms
5,376 KB |
testcase_79 | AC | 175 ms
5,376 KB |
testcase_80 | AC | 200 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; #define rep(i, n) for(int i=0;i<(n);++i) #define rep1(i, n) for(int i=1;i<=(n);i++) #define ll long long using mint = modint998244353; using P = pair<ll,ll>; using lb = long double; using T = tuple<ll, ll, ll>; #ifdef LOCAL # include <debug_print.hpp> # define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else # define dbg(...) (static_cast<void>(0)) #endif template<typename T> struct Matrix { int h, w; vector<vector<T>> d; Matrix() {} //初期化のときは Matrix<> a(h, w) Matrix(int h, int w, T val=0): h(h), w(w), d(h, vector<T>(w,val)) {} Matrix& unit() { assert(h == w); rep(i,h) d[i][i] = 1; return *this; } const vector<T>& operator[](int i) const { return d[i];} vector<T>& operator[](int i) { return d[i];} Matrix operator*(const Matrix& a) const { assert(w == a.h); Matrix r(h, a.w); rep(i,h)rep(k,w)rep(j,a.w) { r[i][j] += d[i][k]*a[k][j]; } return r; } //Matcix<> newa = a.pow(k)と使う Matrix pow(long long t) const { assert(h == w); if (!t) return Matrix(h,h).unit(); if (t == 1) return *this; Matrix r = pow(t>>1); r = r*r; if (t&1) r = r*(*this); return r; } }; // p/q struct fraction{ ll p,q; fraction(ll P = 0, ll Q = 1): p(P), q(Q){} bool operator<(const fraction &other)const{ return p*other.q < other.p*q; } bool operator<=(const fraction &other)const{ return p*other.q <= other.p*q; } }; int main() { int q; cin >> q; ll x1, y1, x2, y2, x3, y3; cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3; ll a = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2); ll b = (x2-x3)*(x2-x3)+(y2-y3)*(y2-y3); ll c = (x3-x1)*(x3-x1)+(y3-y1)*(y3-y1); __int128_t r; if(a+b<c){ __int128_t Mx = max(x1,x3); __int128_t mx = min(x1,x3); __int128_t My = max(y1,y3); __int128_t my = min(y1,y3); r = (Mx-mx) * (Mx-mx) + (My-my)*(My-my); __int128_t xg = (mx+Mx); __int128_t yg = (my+My); dbg(r); rep(i,q){ ll X, Y; cin >> X >> Y; __int128_t x = X*2 ; __int128_t y = Y*2 ; __int128_t R = (xg-x)*(xg-x) + (yg-y) * (yg-y); if(R<=r) { cout << "Yes" << "\n"; } else{ cout << "No" << "\n"; } } return 0; } else if(a+c<b){ __int128_t Mx = max(x2,x3); __int128_t mx = min(x2,x3); __int128_t My = max(y2,y3); __int128_t my = min(y2,y3); r = (Mx-mx) * (Mx-mx) + (My-my)*(My-my); __int128_t xg = (mx+Mx); __int128_t yg = (my+My); dbg(r); rep(i,q){ ll X, Y; cin >> X >> Y; __int128_t x = X*2 ; __int128_t y = Y*2 ; __int128_t R = (xg-x)*(xg-x) + (yg-y) * (yg-y); if(R<=r) { cout << "Yes" << "\n"; } else{ cout << "No" << "\n"; } } return 0; } else if(b+c<a){ __int128_t Mx = max(x1,x2); __int128_t mx = min(x1,x2); __int128_t My = max(y1,y2); __int128_t my = min(y1,y2); r = (Mx-mx) * (Mx-mx) + (My-my)*(My-my); __int128_t xg = (mx+Mx); __int128_t yg = (my+My); dbg(r); rep(i,q){ ll X, Y; cin >> X >> Y; __int128_t x = X*2 ; __int128_t y = Y*2 ; __int128_t R = (xg-x)*(xg-x) + (yg-y) * (yg-y); if(R<=r) { cout << "Yes" << "\n"; } else{ cout << "No" << "\n"; } } return 0; } if((x2-x1)*(y3-y1) == (x3-x1)*(y2-y1)){ __int128_t Mx = max(x1, max(x2,x3)); __int128_t mx = min(x1, min(x2, x3)); __int128_t My = max(y1,max(y2, y3)); __int128_t my = min(y1,min(y2, y3)); r = (Mx-mx) * (Mx-mx) + (My-my)*(My-my); __int128_t xg = (mx+Mx); __int128_t yg = (my+My); dbg(r); rep(i,q){ ll X, Y; cin >> X >> Y; __int128_t x = X*2 ; __int128_t y = Y*2 ; __int128_t R = (xg-x)*(xg-x) + (yg-y) * (yg-y); if(R<=r) { cout << "Yes" << "\n"; } else{ cout << "No" << "\n"; } } } else{ __int128_t det = (x2-x1)*(y3-y1) - (x3-x1)*(y2-y1); Matrix<__int128_t> m(2,2); m[1][1] = x2-x1; m[0][1] = -y2+y1; m[0][0] = y3-y1; m[1][0] = -x3+x1; Matrix<__int128_t> f(2,1); f[0][0] = x2*x2+y2*y2 - x1*x1-y1*y1; f[1][0] = x3*x3+y3*y3 - x1*x1-y1*y1; dbg(det); Matrix<__int128_t> e = m*f; r = (e[0][0]-2*det*x1) * (e[0][0]-2*det*x1) + (e[1][0]-2*det*y1) * (e[1][0] - 2*det*y1); dbg(e[0][0], e[1][0]); dbg(r); rep(i,q){ ll X, Y; cin >> X >> Y; __int128_t x = X*2*det ; __int128_t y = Y*2*det ; __int128_t R = (e[0][0]-x)*(e[0][0]-x) + (e[1][0]-y) * (e[1][0]-y); dbg(r, R); if(R<=r) { cout << "Yes" << "\n"; } else{ cout << "No" << "\n"; } } } return 0; }