結果

問題 No.2602 Real Collider
ユーザー InTheBloomInTheBloom
提出日時 2024-01-12 22:11:53
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 2,278 bytes
コンパイル時間 3,749 ms
コンパイル使用メモリ 170,244 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-01-12 22:12:04
合計ジャッジ時間 10,992 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,548 KB
testcase_01 AC 1 ms
6,548 KB
testcase_02 AC 1 ms
6,548 KB
testcase_03 AC 1 ms
6,548 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 52 ms
6,548 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main () {
    // とりあえず半径を出す
    // https://www.geogebra.org/m/MFRYfNPG
    // https://高校数学.net/bekutoru-menseki/

    int Q = readln.chomp.to!int;
    auto input = readln.split.to!(int[]);
    auto A = tuple(input[0], input[1]);
    auto B = tuple(input[2], input[3]);
    auto C = tuple(input[4], input[5]);

    int bx = B[0]-A[0];
    int by = B[1]-A[1];
    int cx = C[0]-A[0];
    int cy = C[1]-A[1];
    double S = abs(bx*cy - by*cx) / 2.;

    double r;
    if (S < 0.1) {
        r = max(dist(A, B), dist(A, C), dist(B, C)) / 2;
    }
    else {
        r = (dist(A, B)*dist(B, C)*dist(C, A)) / (4*S);
    }

    // 外心を出すのがだるい!
    // https://toy1972.hatenablog.com/entry/2021/11/05/063856
    Tuple!(double, double) center;
    if (S < 0.1) {
        double M = max(dist(A, B), dist(A, C), dist(B, C));
        if (dist(A, B) == M) {
            center = tuple((A[0]+B[0])/2., (A[1]+B[1])/2.);
        }
        else if (dist(A, C) == M) {
            center = tuple((A[0]+C[0])/2., (A[1]+C[1])/2.);
        }
        else {
            center = tuple((C[0]+B[0])/2., (C[1]+B[1])/2.);
        }
    }
    else {
        double sinA = dist(B, C) / (2*r);
        double sinB = dist(A, C) / (2*r);
        double sinC = dist(A, B) / (2*r);

        double degA = asin(sinA);
        double degB = asin(sinB);
        double degC = asin(sinC);

        double sin2A = sin(2*degA);
        double sin2B = sin(2*degB);
        double sin2C = sin(2*degC);

        double deno = sin2A + sin2B + sin2C;
        double X = A[0]*sin2A + B[0]*sin2B + C[0]*sin2C;
        double Y = A[1]*sin2A + B[1]*sin2B + C[1]*sin2C;

        center = tuple(X/deno, Y/deno);
    }

    const double eps = 0.01;
    foreach (_; 0..Q) {
        int X, Y; readln.read(X, Y);
        auto P = tuple(X.to!double, Y.to!double);
        if (dist(center, P) <= r + eps) {
            writeln("Yes");
        }
        else {
            writeln("No");
        }
    }
}

double dist (T) (Tuple!(T, T) A, Tuple!(T, T) B) {
    return sqrt(((A[0]-B[0])^^2 + (A[1]-B[1])^^2).to!double);
}

void read (T...) (string S, ref T args) {
    auto buf = S.split;
    foreach (i, ref arg; args) {
        arg = buf[i].to!(typeof(arg));
    }
}
0