結果
| 問題 |
No.2602 Real Collider
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-12 22:11:53 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,278 bytes |
| コンパイル時間 | 4,231 ms |
| コンパイル使用メモリ | 179,608 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-27 22:38:42 |
| 合計ジャッジ時間 | 11,525 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 76 |
ソースコード
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));
}
}