結果

問題 No.2602 Real Collider
ユーザー maeshunmaeshun
提出日時 2024-01-13 13:49:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,038 bytes
コンパイル時間 4,942 ms
コンパイル使用メモリ 267,224 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-13 13:49:57
合計ジャッジ時間 19,750 ms
ジャッジサーバーID
(参考情報)
judge11 / 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 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 385 ms
6,676 KB
testcase_11 AC 138 ms
6,676 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 105 ms
6,676 KB
testcase_16 AC 159 ms
6,676 KB
testcase_17 AC 178 ms
6,676 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 211 ms
6,676 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 104 ms
6,676 KB
testcase_27 WA -
testcase_28 AC 174 ms
6,676 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 161 ms
6,676 KB
testcase_32 AC 138 ms
6,676 KB
testcase_33 AC 161 ms
6,676 KB
testcase_34 AC 170 ms
6,676 KB
testcase_35 AC 105 ms
6,676 KB
testcase_36 AC 102 ms
6,676 KB
testcase_37 AC 179 ms
6,676 KB
testcase_38 AC 184 ms
6,676 KB
testcase_39 AC 178 ms
6,676 KB
testcase_40 AC 84 ms
6,676 KB
testcase_41 AC 198 ms
6,676 KB
testcase_42 AC 180 ms
6,676 KB
testcase_43 AC 166 ms
6,676 KB
testcase_44 AC 206 ms
6,676 KB
testcase_45 AC 128 ms
6,676 KB
testcase_46 AC 119 ms
6,676 KB
testcase_47 AC 181 ms
6,676 KB
testcase_48 AC 135 ms
6,676 KB
testcase_49 AC 115 ms
6,676 KB
testcase_50 AC 90 ms
6,676 KB
testcase_51 AC 96 ms
6,676 KB
testcase_52 AC 68 ms
6,676 KB
testcase_53 AC 166 ms
6,676 KB
testcase_54 AC 128 ms
6,676 KB
testcase_55 AC 143 ms
6,676 KB
testcase_56 AC 139 ms
6,676 KB
testcase_57 AC 133 ms
6,676 KB
testcase_58 AC 50 ms
6,676 KB
testcase_59 AC 157 ms
6,676 KB
testcase_60 AC 145 ms
6,676 KB
testcase_61 AC 110 ms
6,676 KB
testcase_62 AC 167 ms
6,676 KB
testcase_63 AC 189 ms
6,676 KB
testcase_64 AC 221 ms
6,676 KB
testcase_65 AC 110 ms
6,676 KB
testcase_66 AC 177 ms
6,676 KB
testcase_67 AC 82 ms
6,676 KB
testcase_68 AC 97 ms
6,676 KB
testcase_69 AC 70 ms
6,676 KB
testcase_70 AC 83 ms
6,676 KB
testcase_71 AC 107 ms
6,676 KB
testcase_72 AC 162 ms
6,676 KB
testcase_73 AC 131 ms
6,676 KB
testcase_74 AC 163 ms
6,676 KB
testcase_75 AC 175 ms
6,676 KB
testcase_76 AC 150 ms
6,676 KB
testcase_77 AC 161 ms
6,676 KB
testcase_78 AC 201 ms
6,676 KB
testcase_79 AC 172 ms
6,676 KB
testcase_80 AC 198 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
  }
};


int main()
{
    int q;
    cin >> q;
    ll x1, y1, x2, y2, x3, y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    __int128_t r;
    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;
            x *= 2 ;
            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;
            x *= 2 *det;
            y *= 2 *det;
            __int128_t R = (e[0][0]-x)*(e[0][0]-x) + (e[1][0]-y) * (e[1][0]-y);
            dbg(R);
            if(R<=r) {
                cout << "Yes" << "\n";
            }
            else{
                cout << "No" << "\n";
            }
        }
    }
    return 0;
}
0