結果
問題 | No.2602 Real Collider |
ユーザー |
|
提出日時 | 2024-01-12 21:30:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 2,097 bytes |
コンパイル時間 | 1,573 ms |
コンパイル使用メモリ | 170,968 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-27 21:22:30 |
合計ジャッジ時間 | 7,365 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 78 |
ソースコード
// 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; }