結果

問題 No.2602 Real Collider
ユーザー ococonomy1ococonomy1
提出日時 2024-01-12 22:37:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,403 bytes
コンパイル時間 1,726 ms
コンパイル使用メモリ 123,596 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-12 22:38:16
合計ジャッジ時間 65,739 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 710 ms
6,676 KB
testcase_01 AC 710 ms
6,676 KB
testcase_02 AC 711 ms
6,676 KB
testcase_03 AC 737 ms
6,676 KB
testcase_04 AC 711 ms
6,676 KB
testcase_05 WA -
testcase_06 AC 713 ms
6,676 KB
testcase_07 AC 736 ms
6,676 KB
testcase_08 AC 739 ms
6,676 KB
testcase_09 AC 711 ms
6,676 KB
testcase_10 AC 801 ms
6,676 KB
testcase_11 WA -
testcase_12 AC 748 ms
6,676 KB
testcase_13 AC 751 ms
6,676 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 757 ms
6,676 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 754 ms
6,676 KB
testcase_23 AC 731 ms
6,676 KB
testcase_24 WA -
testcase_25 AC 752 ms
6,676 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'void solve()':
main.cpp:95:38: warning: 'cy' may be used uninitialized [-Wmaybe-uninitialized]
   95 |         if((cx - x) * (cx - x) + (cy - y) * (cy - y) > r2){
      |                                  ~~~~^~~~
main.cpp:78:12: note: 'cy' was declared here
   78 |     int cx,cy;
      |            ^~
main.cpp:95:16: warning: 'cx' may be used uninitialized [-Wmaybe-uninitialized]
   95 |         if((cx - x) * (cx - x) + (cy - y) * (cy - y) > r2){
      |            ~~~~^~~~
main.cpp:78:9: note: 'cx' was declared here
   78 |     int cx,cy;
      |         ^~

ソースコード

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<int,int> ococo_gaisetuen_tyuusin(int x1,int y1,int x2,int y2,int x3,int y3){
    int a = x1,b = y1,c = x2,d = y2,e = x3,f = y3;
    int bunsiy = (e - a) * (a * a + b * b - c * c - d * d) - (c - a) * (a * a + b * b - e * e - f * f);
    int bunboy = 2 * (e - a) * (b - d) - 2 * (c - a) * (b - f);
    
    if(bunboy == 0){
        //この時、一直線に並んでいる
        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);
    }

    int 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<int,int> tyokkei(int x1,int y1,int x2,int y2){
    pair<int,int> 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;
    int xa,ya,xb,yb,xc,yc;
    cin >> xa >> ya >> xb >> yb >> xc >> yc;
    vector<pii> kouho = {ococo_gaisetuen_tyuusin(xa,ya,xb,yb,xc,yc),tyokkei(xa,ya,xb,yb),tyokkei(xb,yb,xc,yc),tyokkei(xc,yc,xa,ya)};
    int cx,cy;
    int r2 = INT_MAX;
    for(int x = -10000; x <= 10000; x++){
        for(int y = -10000; y <= 10000; y++){
            int val = max({(x - xa) * (x - xa) + (y - ya) * (y - ya),(x - xb) * (x - xb) + (y - yb) * (y - yb),(x - xc) * (x - xc) + (y - yc) * (y - yc)});
            if(val < r2){
                cx = x;
                cy = y;
                r2 = val;
            }
        }
    }

    
    while(q--){
        int x,y;
        cin >> x >> y;
        if((cx - x) * (cx - x) + (cy - y) * (cy - 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