結果
問題 | No.2602 Real Collider |
ユーザー | Rubikun |
提出日時 | 2024-01-12 21:24:57 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 13,048 bytes |
コンパイル時間 | 3,016 ms |
コンパイル使用メモリ | 222,420 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-27 21:04:35 |
合計ジャッジ時間 | 9,933 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | WA | - |
testcase_02 | AC | 4 ms
6,940 KB |
testcase_03 | AC | 3 ms
6,940 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 32 ms
6,940 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 24 ms
6,940 KB |
testcase_16 | AC | 38 ms
6,940 KB |
testcase_17 | AC | 42 ms
6,940 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 48 ms
6,940 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 24 ms
6,940 KB |
testcase_27 | WA | - |
testcase_28 | AC | 44 ms
6,940 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 38 ms
6,944 KB |
testcase_32 | AC | 33 ms
6,940 KB |
testcase_33 | AC | 38 ms
6,940 KB |
testcase_34 | AC | 39 ms
6,940 KB |
testcase_35 | AC | 24 ms
6,940 KB |
testcase_36 | AC | 24 ms
6,940 KB |
testcase_37 | AC | 41 ms
6,940 KB |
testcase_38 | AC | 42 ms
6,940 KB |
testcase_39 | AC | 42 ms
6,940 KB |
testcase_40 | AC | 20 ms
6,944 KB |
testcase_41 | AC | 47 ms
6,940 KB |
testcase_42 | AC | 36 ms
6,940 KB |
testcase_43 | AC | 37 ms
6,948 KB |
testcase_44 | AC | 47 ms
6,940 KB |
testcase_45 | AC | 30 ms
6,940 KB |
testcase_46 | AC | 28 ms
6,940 KB |
testcase_47 | AC | 42 ms
6,944 KB |
testcase_48 | AC | 32 ms
6,944 KB |
testcase_49 | AC | 27 ms
6,940 KB |
testcase_50 | AC | 22 ms
6,944 KB |
testcase_51 | AC | 23 ms
6,940 KB |
testcase_52 | AC | 17 ms
6,944 KB |
testcase_53 | AC | 39 ms
6,944 KB |
testcase_54 | AC | 30 ms
6,944 KB |
testcase_55 | AC | 33 ms
6,944 KB |
testcase_56 | AC | 33 ms
6,944 KB |
testcase_57 | AC | 31 ms
6,944 KB |
testcase_58 | AC | 13 ms
6,944 KB |
testcase_59 | AC | 36 ms
6,944 KB |
testcase_60 | AC | 34 ms
6,940 KB |
testcase_61 | AC | 26 ms
6,940 KB |
testcase_62 | AC | 39 ms
6,940 KB |
testcase_63 | AC | 44 ms
6,940 KB |
testcase_64 | AC | 50 ms
6,944 KB |
testcase_65 | AC | 26 ms
6,940 KB |
testcase_66 | AC | 41 ms
6,944 KB |
testcase_67 | AC | 21 ms
6,944 KB |
testcase_68 | AC | 24 ms
6,940 KB |
testcase_69 | AC | 17 ms
6,940 KB |
testcase_70 | AC | 20 ms
6,944 KB |
testcase_71 | AC | 25 ms
6,940 KB |
testcase_72 | AC | 38 ms
6,944 KB |
testcase_73 | AC | 30 ms
6,944 KB |
testcase_74 | AC | 38 ms
6,944 KB |
testcase_75 | AC | 41 ms
6,940 KB |
testcase_76 | AC | 35 ms
6,944 KB |
testcase_77 | AC | 38 ms
6,940 KB |
testcase_78 | AC | 46 ms
6,940 KB |
testcase_79 | AC | 40 ms
6,944 KB |
testcase_80 | AC | 46 ms
6,944 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } #define all(x) (x).begin(),(x).end() #define fi first #define se second #define mp make_pair #define si(x) int(x.size()) const int mod=998244353,MAX=300005,INF=1<<30; //幾何ライブラリ // define double ll をするときは Point の < と == も書き換えよう! const double eps=1e-8; const double pi=acos((double)-1.0L); #define equals(a,b) (fabs((a)-(b))<eps) double torad(double deg) {return (double)(deg)*pi/180.0;} double todeg(double ang) {return ang*180.0/pi;} class Point{ public: double x,y; Point(double x=0,double y=0):x(x),y(y){} Point operator + (Point p){return Point(x+p.x,y+p.y);} Point operator - (Point p){return Point(x-p.x,y-p.y);} Point operator * (double a){return Point(a*x,a*y);} Point operator / (double a){return Point(x/a,y/a);} double abs(){return sqrt(norm());} double norm(){return x*x+y*y;} bool operator < (const Point &p)const{ return x+eps<p.x||(equals(x,p.x)&&y+eps<p.y); //return x<p.x||(x==p.x&&y<p.y); } bool operator == (const Point &p)const{ return fabs(x-p.x)<eps/100000&&fabs(y-p.y)<eps/100000; //return x==p.x&&y==p.y; } }; typedef Point Vector; double norm(Vector a){ return a.x*a.x+a.y*a.y; } double abs(Vector a){ return sqrt(norm(a)); } double dot(Vector a,Vector b){ return a.x*b.x+a.y*b.y; } double cross(Vector a,Vector b){ return a.x*b.y-a.y*b.x; } struct Segment{ Point p1,p2; }; bool isOrthogonal(Vector a,Vector b){ return equals(dot(a,b),0.0); } bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){ return isOrthogonal(a1-a2,b1-b2); } bool isOrthogonal(Segment s1,Segment s2){ return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0); } bool isParallel(Vector a,Vector b){ return equals(cross(a,b),0.0); } bool isParallel(Point a1,Point a2,Point b1,Point b2){ return isParallel(a1-a2,b1-b2); } bool isParallel(Segment s1,Segment s2){ return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0); } Point project(Segment s,Point p){ Vector base=s.p2-s.p1; double r=dot(p-s.p1,base)/norm(base); return s.p1+base*r; } Point reflect(Segment s,Point p){ return p+(project(s,p)-p)*2.0; } Point turn(Point p,Point c,double pi){ double q=atan2(p.y-c.y,p.x-c.x); q+=pi; p=c+Point{cos(q)*abs(p-c),sin(q)*abs(p-c)}; return p; } //pをcを中心としてpi回転させる(1周で2π) //p=cのときnan //p0,p1,p2の順に見たときどうなるか? static const int counter_clockwise=1; static const int clockwise=-1; static const int online_back=2; static const int online_front=-2; static const int on_segment=0; int ccw(Point p0,Point p1,Point p2){ Vector a=p1-p0; Vector b=p2-p0; if(cross(a,b)>eps) return counter_clockwise; if(cross(a,b)<-eps) return clockwise; if(dot(a,b)<-eps) return online_back; if(a.norm()<b.norm()) return online_front; return on_segment; } bool intersect(Point p1,Point p2,Point p3,Point p4){ return(ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0&&ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0); } bool intersect(Segment s1,Segment s2){ return intersect(s1.p1,s1.p2,s2.p1,s2.p2); } bool overlap(Segment s1,Segment s2){ int a=ccw(s1.p1,s1.p2,s2.p1),b=ccw(s1.p1,s1.p2,s2.p2); if(a&1||b&1) return 0; if(a==2){ if(b==-2||(b==0&&!(s2.p2==s1.p1))) return 1; else return 0; } if(a==-2){ if(b==2||(b==0&&!(s2.p2==s1.p2))) return 1; else return 0; } if(a==0){ if(s1.p1==s2.p1){ if(b!=2) return 1; else return 0; } else if(s1.p2==s2.p1){ if(b!=-2) return 1; else return 0; } else return 1; } return 0; } //s1とs2の共通の線分(長さ0より大きい)があるかどうか typedef Segment Line; double getDistance(Point a,Point b){ return abs(a-b); } double getDistanceLP(Line l,Point p){ return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1)); } double getDistanceSP(Segment s,Point p){ if(dot(s.p2-s.p1,p-s.p1)<0.0) return abs(p-s.p1); if(dot(s.p1-s.p2,p-s.p2)<0.0) return abs(p-s.p2); return getDistanceLP(s,p); } double getDistance(Segment s1,Segment s2){ if(intersect(s1,s2)) return 0.0; return min({getDistanceSP(s1,s2.p1),getDistanceSP(s1,s2.p2),getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)}); } Point getCrossPointS(Segment s1,Segment s2){ //if(ccw(s1.p1,s1.p2,s2.p1)==0&&ccw(s1.p1,s1.p2,s2.p2)==0) return s1.p1; Vector base=s2.p2-s2.p1; double d1=abs(cross(base,s1.p1-s2.p1)); double d2=abs(cross(base,s1.p2-s2.p1)); double t=d1/(d1+d2); return s1.p1+(s1.p2-s1.p1)*t; }//同じ時壊れます Point getCrossPointL(Line l1,Line l2){ //if(ccw(s1.p1,s1.p2,s2.p1)==0&&ccw(s1.p1,s1.p2,s2.p2)==0) return s1.p1; Vector v1=l1.p2-l1.p1,v2=l2.p2-l2.p1; return l1.p1+v1*cross(v2,l2.p1-l1.p1)/cross(v2,v1); } Segment ParallelSegment(Segment s,double d){ Vector v={-(s.p2-s.p1).y,(s.p2-s.p1).x}; v=v/abs(v); s.p1=s.p1+v*d; s.p2=s.p2+v*d; return s; } Point naisin(Point p1,Point p2,Point p3){ if(p1==p2&&p2==p3&&p3==p1) return p1; return (p1*abs(p2-p3)+p2*abs(p1-p3)+p3*abs(p1-p2))/(abs(p2-p3)+abs(p1-p3)+abs(p1-p2)); } Point naisin(Line l1,Line l2,Line l3){ //平行でない前提 Point p1=getCrossPointL(l1,l2),p2=getCrossPointL(l1,l3),p3=getCrossPointL(l2,l3); return naisin(p1,p2,p3); } //ネットの適当を書いたのであってるか全く知りません→あってそう class Circle{ public: Point c; double r; Circle(Point c=Point(),double r=0.0):c(c),r(r){} }; Point CircleCenter(Point a,Point b,Point c){ Point u=a-b,v=a-c; double m1=(norm(a)-norm(b))/2.0,m2=(norm(a)-norm(c))/2.0; Point res; if(cross(u,v)==0.0){ res.x=1e9; res.y=1e9; return res; } res.x=(m1*v.y-m2*u.y)/cross(u,v); res.y=(m1*v.x-m2*u.x)/cross(v,u); return res; } //3点を通る円の中心を返す //交わる 0 // c1がc2のinside 1 // c1がc2のoutside 2 // 交わらない 3 int not_intersect(Circle c1,Circle c2){ double d=getDistance(c1.c,c2.c); double r1=c1.r,r2=c2.r; if(r1<r2){ if(d<(r2-r1)) return 1; } if(r1>r2){ if(d<(r1-r2)) return 2; } if(d<=r1+r2) return 0; else return 3; } pair<Point,Point> segCrossPpoints(Circle c,Line l){ //assert(intersect(c,l)); Vector pr=project(l,c.c); Vector e=(l.p2-l.p1)/abs(l.p2-l.p1); double base=sqrt(c.r*c.r-norm(pr-c.c)); return make_pair(pr+e*base,pr-e*base); } double arg(Vector p){return atan2(p.y,p.x);} Vector polar(double a,double r){return Point(cos(r)*a,sin(r)*a);} //inside(outside) pair<Point,Point> getCrossPoints(Circle c1,Circle c2){ //assert(intersect(c1,c2)); double d=abs(c1.c-c2.c); double a=acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d)); double t=arg(c2.c-c1.c); return make_pair(c1.c+polar(c1.r,t+a),c1.c+polar(c1.r,t-a)); } vector<Line> Commontangent(Circle c1,Circle c2){ vector<Line> res; Point p=c2.c-c1.c; if(abs(p)>=(c1.r+c2.r)){ Point a,b; a.x=c1.r*(p.x*(c1.r+c2.r)+p.y*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p); a.y=c1.r*(p.y*(c1.r+c2.r)-p.x*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p); b.x=c1.r*(p.x*(c1.r+c2.r)-p.y*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p); b.y=c1.r*(p.y*(c1.r+c2.r)+p.x*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p); res.push_back(Line{a+c1.c,a+c1.c+Point{-a.y,a.x}}); if(!(a==b)){ res.push_back(Line{b+c1.c,b+c1.c+Point{-b.y,b.x}}); } } if(abs(p)>=abs(c1.r-c2.r)){ Point a,b; a.x=c1.r*(p.x*(c1.r-c2.r)+p.y*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p); a.y=c1.r*(p.y*(c1.r-c2.r)-p.x*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p); b.x=c1.r*(p.x*(c1.r-c2.r)-p.y*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p); b.y=c1.r*(p.y*(c1.r-c2.r)+p.x*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p); res.push_back(Line{a+c1.c,a+c1.c+Point{-a.y,a.x}}); if(!(a==b)){ res.push_back(Line{b+c1.c,b+c1.c+Point{-b.y,b.x}}); } } return res; } typedef vector<Point> Polygon; /* IN 2 ON 1 OUT 0 */ int contains(Polygon g,Point p){ int n=int(g.size()); bool x=false; for(int i=0;i<n;i++){ Point a=g[i]-p,b=g[(i+1)%n]-p; if(a.y>b.y) swap(a,b); if(a.y<eps&&0<b.y&&cross(a,b)<0) x=!x; if(abs(cross(a,b))<eps&&dot(a,b)<eps) return 1; } return (x?2:0); } Polygon andrewScan(Polygon s,bool ok){ Polygon u,l; sort(all(s)); if(int(s.size())<3) return s; int n=int(s.size()); u.push_back(s[0]); u.push_back(s[1]); l.push_back(s[n-1]); l.push_back(s[n-2]); if(ok){ for(int i=2;i<n;i++){ for(int j=int(u.size());j>=2&&ccw(u[j-2],u[j-1],s[i])==counter_clockwise;j--){ u.pop_back(); } u.push_back(s[i]); } for(int i=int(s.size())-3;i>=0;i--){ for(int j=int(l.size());j>=2&&ccw(l[j-2],l[j-1],s[i])==counter_clockwise;j--){ l.pop_back(); } l.push_back(s[i]); } } if(!ok){ for(int i=2;i<n;i++){ for(int j=int(u.size());j>=2&&ccw(u[j-2],u[j-1],s[i])!=clockwise;j--){ u.pop_back(); } u.push_back(s[i]); } for(int i=int(s.size())-3;i>=0;i--){ for(int j=int(l.size());j>=2&&ccw(l[j-2],l[j-1],s[i])!=clockwise;j--){ l.pop_back(); } l.push_back(s[i]); } } reverse(all(l)); for(int i=int(u.size())-2;i>=1;i--) l.push_back(u[i]); return l; }//ok==1なら辺の上も含める Polygon convex_cut(const Polygon& P, const Line& l) { Polygon Q; for(int i=0;i<si(P);i++){ Point A=P[i],B=P[(i+1)%si(P)]; if(ccw(l.p1,l.p2,A)!=-1)Q.push_back(A); if(ccw(l.p1,l.p2,A)*ccw(l.p1,l.p2,B)<0) Q.push_back(getCrossPointL(Line{A,B},l)); } return Q; } double area(Point a,Point b,Point c){ b=b-a; c=c-a; return abs(b.x*c.y-b.y*c.x)/2.0; } /* ll area(Polygon P){ ll sum=0; for(int i=0;i<si(P);i++){ sum+=cross(P[i],P[(i+1)%si(P)]); } return abs(sum); } */ // 倍 double area(Polygon &P){ if(si(P)==0) return 0.0; double res=0; Point c={0.0,0.0}; for(int i=0;i<si(P);i++){ c=c+P[i]; } c=c/si(P); for(int i=0;i<si(P);i++){ res+=area(c,P[i],P[(i+1)%si(P)]); } return res; } ll gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b); } pair<Point,Vector> perpendicular_bisector(Point a,Point b){ Point c=(a+b)/2; Vector v=b-c; swap(v.x,v.y); v.x*=-1; Point p=c; if(v.x==0){ v.y=1; p.y=0; } else if(v.y==0){ v.x=1; p.x=0; } else{ if(v.x<0){ v.x*=-1; v.y*=-1; } ll g=gcd(abs(ll(v.x)),abs(ll(v.y))); v.x/=g; v.y/=g; if(p.x>=0){ ll d=p.x/v.x; p=p-v*d; }else{ ll d=abs(p.x)/v.x; p=p+v*d; if(p.x<0){ p=p+v; } } } return mp(p,v); } //2倍するなりして整数にしておくこと /* Line perpendicular_bisector(Point a,Point b){ Point c=(a+b)/2; Point d=turn(a,c,M_PI/2.0); return {c,d}; } //2倍するなりして整数にしておくこと */ pair<Line,Line> angle_bisector(Line a,Line b){ // assert(!isParallel(a,b)); Point p=getCrossPointL(a,b); if(a.p1==p) swap(a.p1,a.p2); if(b.p1==p) swap(b.p1,b.p2); double kaku1=arg(a.p1-p); double kaku2=arg(b.p1-p); return mp(Line{p,p+polar(1.0,(kaku1+kaku2)/2.0)},Line{p,p+polar(1.0,(kaku1+kaku2+M_PI)/2.0)}); } Line abc_to_line(double a,double b,double c){ if(a==0){ return {{0,-c/b},{1,-c/b}}; }else{ if(b==0){ return {{-c/a,0},{-c/a,1}}; }else{ return {{0,-c/b},{1,-(a+c)/b}}; } } } int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); int Q;cin>>Q; vector<Point> P(3); for(int i=0;i<3;i++) cin>>P[i].x>>P[i].y; Point cen=CircleCenter(P[0],P[1],P[2]); double d=abs(cen-P[0]); while(Q--){ Point X;cin>>X.x>>X.y; if(abs(X-cen)<d+eps) cout<<"Yes\n"; else cout<<"No\n"; } }