結果

問題 No.2602 Real Collider
ユーザー ococonomy1ococonomy1
提出日時 2024-01-12 22:22:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 5,827 bytes
コンパイル時間 1,247 ms
コンパイル使用メモリ 112,260 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-27 22:52:21
合計ジャッジ時間 6,164 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll,int>;
#define TEST cerr << "TEST" << endl
#define AMARI 998244353
// #define AMARI 1000000007
#define TIME_LIMIT 1980000
#define el '\n'
#define El '\n'

//三角形の外心の中心を返す
pair<long double,long double> ococo_gaisetuen_tyuusin(long double x1,long double y1,long double x2,long double y2,long double x3,long double y3){
    long double a = x1,b = y1,c = x2,d = y2,e = x3,f = y3;
    long double bunsiy = (e - a) * (a * a + b * b - c * c - d * d) - (c - a) * (a * a + b * b - e * e - f * f);
    long double bunboy = 2 * (e - a) * (b - d) - 2 * (c - a) * (b - f);
    
    if(abs(bunboy) <= 1e-10){
        //この時、一直線に並んでいる
        if((x1 > x2) == (x2 > x3)){
            return pair((x1 + x3) / 2,(y1 + y3) / 2);
        }
        if((x1 > x3) == (x3 > x2)){
            return pair((x1 + x2) / 2,(y1 + y2) / 2);
        }
        return pair((x2 + x3) / 2,(y2 + y3) / 2);
    }

    long double bunsix,bunbox;
    if(a != c){
        bunsix = 2 * (b - d) * (bunsiy / bunboy) - a * a - b * b + c * c + d * d;
        bunbox = 2 * (c - a);
    }
    else{
        bunsix = 2 * (b - f) * (bunsiy / bunboy) - a * a - b * b + e * e + f * f;
        bunbox = 2 * (e - a);
    }
    return pair(bunsix / bunbox,bunsiy / bunboy);
}

//2点の中心を直径とする円の中心
pair<long double,long double> tyokkei(long double x1,long double y1,long double x2,long double y2){
    pair<long double,long double> ans;
    ans.first = (x1 + x2) / 2;
    ans.second = (y1 + y2) / 2;
    return ans;
}

#define MULTI_TEST_CASE false
void solve(void) {
    //問題を見たらまず「この問題設定から言えること」をいっぱい言ってみる
    //一個解答に繋がりそうな解法が見えても、実装や細かい考察に時間がかかりそうなら別の方針やを考えてみる
    //特に添え字周りはそのままやると面倒&言い換えが有効なことが多いので書き始める前にじっくり考える
    int q;
    cin >> q;
    long double xa,ya,xb,yb,xc,yc;
    cin >> xa >> ya >> xb >> yb >> xc >> yc;
    xa /= 1000; ya /= 1000; xb /= 1000; yb /= 1000;
    xc /= 1000; yc /= 1000;
    long double cx,cy;
    tie(cx,cy) = ococo_gaisetuen_tyuusin(xa,ya,xb,yb,xc,yc);
    long double r2 = (cx - (long double)xa) * (cx - (long double)xa) + (cy - (long double)ya) * (cy - (long double)ya);
    //(a,b)を直径とする円、(b,c)を直径とする円、(c,a)を直径とする円についても考えなければならない
    long double tx,ty;
    tie(tx,ty) = tyokkei(xa,ya,xb,yb);
    if(max({((long double)xa - tx) * ((long double)xa - tx) + ((long double)ya - ty) * ((long double)ya - ty),
        ((long double)xb - tx) * ((long double)xb - tx) + ((long double)yb - ty) * ((long double)yb - ty),
        ((long double)xc - tx) * ((long double)xc - tx) + ((long double)yc - ty) * ((long double)yc - ty)
    }) < r2){
        r2 = max({((long double)xa - tx) * ((long double)xa - tx) + ((long double)ya - ty) * ((long double)ya - ty),
        ((long double)xb - tx) * ((long double)xb - tx) + ((long double)yb - ty) * ((long double)yb - ty),
        ((long double)xc - tx) * ((long double)xc - tx) + ((long double)yc - ty) * ((long double)yc - ty)});
        cx = tx;
        cy = ty;
    }
    tie(tx,ty) = tyokkei(xa,ya,xc,yc);
    if(max({((long double)xa - tx) * ((long double)xa - tx) + ((long double)ya - ty) * ((long double)ya - ty),
        ((long double)xb - tx) * ((long double)xb - tx) + ((long double)yb - ty) * ((long double)yb - ty),
        ((long double)xc - tx) * ((long double)xc - tx) + ((long double)yc - ty) * ((long double)yc - ty)
    }) < r2){
        r2 = max({((long double)xa - tx) * ((long double)xa - tx) + ((long double)ya - ty) * ((long double)ya - ty),
        ((long double)xb - tx) * ((long double)xb - tx) + ((long double)yb - ty) * ((long double)yb - ty),
        ((long double)xc - tx) * ((long double)xc - tx) + ((long double)yc - ty) * ((long double)yc - ty)});
        cx = tx;
        cy = ty;
    }
    tie(tx,ty) = tyokkei(xc,yc,xb,yb);
    if(max({((long double)xa - tx) * ((long double)xa - tx) + ((long double)ya - ty) * ((long double)ya - ty),
        ((long double)xb - tx) * ((long double)xb - tx) + ((long double)yb - ty) * ((long double)yb - ty),
        ((long double)xc - tx) * ((long double)xc - tx) + ((long double)yc - ty) * ((long double)yc - ty)
    }) < r2){
        r2 = max({((long double)xa - tx) * ((long double)xa - tx) + ((long double)ya - ty) * ((long double)ya - ty),
        ((long double)xb - tx) * ((long double)xb - tx) + ((long double)yb - ty) * ((long double)yb - ty),
        ((long double)xc - tx) * ((long double)xc - tx) + ((long double)yc - ty) * ((long double)yc - ty)});
        cx = tx;
        cy = ty;
    }
    
    while(q--){
        long double x,y;
        cin >> x >> y;
        x /= 1000; y /= 1000;
        if((cx - (long double)x) * (cx - (long double)x) + (cy - (long double)y) * (cy - (long double)y) > r2){
            cout << "No" << el;
            continue;
        }
        cout << "Yes" << el;
    }
    return;
}

void calc(void) {
    return;
}

signed main(void) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    calc();
    int t = 1;
    if(MULTI_TEST_CASE) cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}
0