結果

問題 No.2602 Real Collider
ユーザー maeshunmaeshun
提出日時 2024-01-13 14:38:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 5,435 bytes
コンパイル時間 5,373 ms
コンパイル使用メモリ 267,632 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-28 01:28:54
合計ジャッジ時間 17,975 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 WA -
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 371 ms
6,944 KB
testcase_11 AC 132 ms
6,944 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 100 ms
6,940 KB
testcase_16 AC 158 ms
6,944 KB
testcase_17 AC 173 ms
6,944 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 208 ms
6,940 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 103 ms
6,940 KB
testcase_27 WA -
testcase_28 AC 172 ms
6,940 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 155 ms
6,944 KB
testcase_32 AC 139 ms
6,940 KB
testcase_33 AC 160 ms
6,940 KB
testcase_34 AC 162 ms
6,940 KB
testcase_35 AC 100 ms
6,940 KB
testcase_36 AC 97 ms
6,944 KB
testcase_37 AC 170 ms
6,940 KB
testcase_38 AC 177 ms
6,944 KB
testcase_39 AC 172 ms
6,940 KB
testcase_40 AC 83 ms
6,944 KB
testcase_41 AC 201 ms
6,940 KB
testcase_42 AC 149 ms
6,940 KB
testcase_43 AC 159 ms
6,940 KB
testcase_44 AC 197 ms
6,944 KB
testcase_45 AC 125 ms
6,944 KB
testcase_46 AC 120 ms
6,944 KB
testcase_47 AC 177 ms
6,940 KB
testcase_48 AC 136 ms
6,940 KB
testcase_49 AC 113 ms
6,944 KB
testcase_50 AC 89 ms
6,944 KB
testcase_51 AC 94 ms
6,940 KB
testcase_52 AC 67 ms
6,940 KB
testcase_53 AC 163 ms
6,940 KB
testcase_54 AC 126 ms
6,940 KB
testcase_55 AC 139 ms
6,940 KB
testcase_56 AC 138 ms
6,944 KB
testcase_57 AC 127 ms
6,940 KB
testcase_58 AC 48 ms
6,940 KB
testcase_59 AC 151 ms
6,940 KB
testcase_60 AC 142 ms
6,944 KB
testcase_61 AC 106 ms
6,944 KB
testcase_62 AC 162 ms
6,944 KB
testcase_63 AC 185 ms
6,944 KB
testcase_64 AC 211 ms
6,940 KB
testcase_65 AC 104 ms
6,944 KB
testcase_66 AC 172 ms
6,944 KB
testcase_67 AC 80 ms
6,944 KB
testcase_68 AC 96 ms
6,944 KB
testcase_69 AC 70 ms
6,944 KB
testcase_70 AC 80 ms
6,940 KB
testcase_71 AC 103 ms
6,944 KB
testcase_72 AC 156 ms
6,944 KB
testcase_73 AC 129 ms
6,940 KB
testcase_74 AC 160 ms
6,940 KB
testcase_75 AC 170 ms
6,940 KB
testcase_76 AC 149 ms
6,944 KB
testcase_77 AC 158 ms
6,940 KB
testcase_78 AC 194 ms
6,944 KB
testcase_79 AC 166 ms
6,944 KB
testcase_80 AC 190 ms
6,944 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;
  }
};

// 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";
            }
        }
    }
    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";
            }
        }
    }
    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";
            }
        }
    }
    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