結果

問題 No.2602 Real Collider
ユーザー TairitsuMeowTairitsuMeow
提出日時 2024-01-12 21:30:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 2,097 bytes
コンパイル時間 2,077 ms
コンパイル使用メモリ 172,008 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-12 21:30:43
合計ジャッジ時間 8,493 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// Problem: No.2602 Real Collider
// Contest: yukicoder
// URL: https://yukicoder.me/problems/no/2602
// Memory Limit: 512 MB
// Time Limit: 2000 ms

#include<bits/stdc++.h>
#define debug(x) cerr<<(#x)<<" "<<(x)<<endl
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<ll,ll>
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define per(i,a,b) for(ll i=(a);i>=(b);--i)
using namespace std;
bool Mbe; 
ll read(){
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
const ll N=1e6+9;
const ld eps=1e-9;
ll n,T;
struct Pt{
	ld x,y;
}pts[N];
Pt operator +(Pt a,Pt b){return (Pt){a.x+b.x,a.y+b.y};}
Pt operator -(Pt a,Pt b){return (Pt){a.x-b.x,a.y-b.y};}
Pt operator *(Pt a,ld b){return (Pt){a.x*b,a.y*b};}
Pt operator /(Pt a,ld b){return (Pt){a.x/b,a.y/b};}
ld cross(Pt a,Pt b){return a.x*b.y-a.y*b.x;}
ld dot(Pt a,Pt b){return a.x*b.x+a.y*b.y;}
ld dis(Pt a,Pt b){return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}
Pt mid(Pt a,Pt b){return (Pt){(a.x+b.x)/2,(a.y+b.y)/2};}
Pt rot(Pt a){return (Pt){-a.y,a.x};}
struct Circ{
	Pt o;ld r;
};
Circ calc(Pt t1,Pt t2,Pt t3){
	Pt v1=rot(t2-t1),v2=rot(t1-t3);
	Pt p1=mid(t1,t2),p2=mid(t1,t3);
	Pt u=p1-p2;
	ld t=cross(v2,u)/cross(v1,v2);
	Pt z=p1+v1*t;
	return (Circ){z,dis(z,t1)};
}
mt19937 rnd(time(0));
bool Med;
int main(){
	cerr<<fabs(&Med-&Mbe)/1048576.0<<"MB\n";
	ios::sync_with_stdio(0);
	n=3;cin>>T;
	rep(i,1,n)cin>>pts[i].x>>pts[i].y;
	shuffle(pts+1,pts+n+1,rnd);
	Circ C=(Circ){pts[1],0};
	rep(i,2,n){
		if(dis(pts[i],C.o)>C.r+eps){
			C=(Circ){pts[i],0};
			rep(j,1,i-1){
				if(dis(pts[j],C.o)>C.r+eps){
					C=(Circ){mid(pts[i],pts[j]),dis(pts[i],pts[j])/2};
					rep(k,1,j-1){
						if(dis(pts[k],C.o)>C.r+eps)C=calc(pts[i],pts[j],pts[k]);
					}
				}
			}
		}
	}
	while(T--){
		ld x,y;cin>>x>>y;
		ld d=(x-C.o.x)*(x-C.o.x)+(y-C.o.y)*(y-C.o.y);
		if(d<C.r*C.r+eps)puts("Yes");
		else puts("No");
	}
	return 0;
}
0