結果

問題 No.2602 Real Collider
ユーザー maeshunmaeshun
提出日時 2024-01-13 14:05:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,089 bytes
コンパイル時間 4,906 ms
コンパイル使用メモリ 267,224 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-01-13 14:05:21
合計ジャッジ時間 19,409 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 1 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 370 ms
6,548 KB
testcase_11 AC 135 ms
6,548 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 99 ms
6,548 KB
testcase_16 AC 161 ms
6,548 KB
testcase_17 AC 174 ms
6,548 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 209 ms
6,548 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 101 ms
6,548 KB
testcase_27 WA -
testcase_28 AC 168 ms
6,548 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 160 ms
6,548 KB
testcase_32 AC 132 ms
6,548 KB
testcase_33 AC 160 ms
6,548 KB
testcase_34 AC 160 ms
6,548 KB
testcase_35 AC 99 ms
6,548 KB
testcase_36 AC 100 ms
6,548 KB
testcase_37 AC 176 ms
6,548 KB
testcase_38 AC 178 ms
6,548 KB
testcase_39 AC 171 ms
6,548 KB
testcase_40 AC 82 ms
6,548 KB
testcase_41 AC 200 ms
6,548 KB
testcase_42 AC 148 ms
6,548 KB
testcase_43 AC 152 ms
6,548 KB
testcase_44 AC 198 ms
6,548 KB
testcase_45 AC 122 ms
6,548 KB
testcase_46 AC 115 ms
6,548 KB
testcase_47 AC 175 ms
6,548 KB
testcase_48 AC 129 ms
6,548 KB
testcase_49 AC 114 ms
6,548 KB
testcase_50 AC 90 ms
6,548 KB
testcase_51 AC 94 ms
6,548 KB
testcase_52 AC 66 ms
6,548 KB
testcase_53 AC 164 ms
6,548 KB
testcase_54 AC 126 ms
6,548 KB
testcase_55 AC 139 ms
6,548 KB
testcase_56 AC 137 ms
6,548 KB
testcase_57 AC 124 ms
6,548 KB
testcase_58 AC 49 ms
6,548 KB
testcase_59 AC 149 ms
6,548 KB
testcase_60 AC 140 ms
6,548 KB
testcase_61 AC 105 ms
6,548 KB
testcase_62 AC 155 ms
6,548 KB
testcase_63 AC 181 ms
6,548 KB
testcase_64 AC 208 ms
6,548 KB
testcase_65 AC 105 ms
6,548 KB
testcase_66 AC 173 ms
6,548 KB
testcase_67 AC 79 ms
6,548 KB
testcase_68 AC 93 ms
6,548 KB
testcase_69 AC 66 ms
6,548 KB
testcase_70 AC 80 ms
6,548 KB
testcase_71 AC 101 ms
6,548 KB
testcase_72 AC 155 ms
6,548 KB
testcase_73 AC 127 ms
6,548 KB
testcase_74 AC 156 ms
6,548 KB
testcase_75 AC 170 ms
6,548 KB
testcase_76 AC 148 ms
6,548 KB
testcase_77 AC 155 ms
6,548 KB
testcase_78 AC 188 ms
6,548 KB
testcase_79 AC 164 ms
6,548 KB
testcase_80 AC 184 ms
6,548 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;
            __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;
}
0