結果

問題 No.2602 Real Collider
ユーザー Taiki0715Taiki0715
提出日時 2024-01-12 21:54:33
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 341 ms / 2,000 ms
コード長 6,392 bytes
コンパイル時間 11,155 ms
コンパイル使用メモリ 178,944 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-27 22:01:30
合計ジャッジ時間 17,025 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 78
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
template<int mod>istream &operator>>(istream &is,static_modint<mod> &a){long long b;is>>b;a=b;return is;}
istream &operator>>(istream &is,modint &a){long long b;cin>>b;a=b;return is;}
#endif
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) static_cast<void>(0)
#define debugg(...) static_cast<void>(0)
template<typename T1,typename T2>ostream &operator<<(ostream &os,const pair<T1,T2>&p){os<<p.first<<' '<<p.second;return os;}
#endif
using ll=long long;
using ull=unsigned long long;
using P=pair<ll,ll>;
template<typename T>using minque=priority_queue<T,vector<T>,greater<T>>;
template<typename T>bool chmax(T &a,const T &b){return (a<b?(a=b,true):false);}
template<typename T>bool chmin(T &a,const T &b){return (a>b?(a=b,true):false);}
template<typename T1,typename T2>istream &operator>>(istream &is,pair<T1,T2>&p){is>>p.first>>p.second;return is;}
template<typename T>istream &operator>>(istream &is,vector<T> &a){for(auto &i:a)is>>i;return is;}
template<typename T1,typename T2>void operator++(pair<T1,T2>&a,int n){a.first++,a.second++;}
template<typename T1,typename T2>void operator--(pair<T1,T2>&a,int n){a.first--,a.second--;}
template<typename T>void operator++(vector<T>&a,int n){for(auto &i:a)i++;}
template<typename T>void operator--(vector<T>&a,int n){for(auto &i:a)i--;}
#define reps(i,a,n) for(int i=(a);i<(n);i++)
#define rep(i,n) reps(i,0,n)
#define all(x) x.begin(),x.end()
#define pcnt(x) __builtin_popcountll(x)
ll myceil(ll a,ll b){return (a+b-1)/b;}
template<typename T,size_t n,size_t id=0>
auto vec(const int (&d)[n],const T &init=T()){
  if constexpr (id<n)return vector(d[id],vec<T,n,id+1>(d,init));
  else return init;
}
void SOLVE();
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  #ifdef LOCAL
  clock_t start=clock();
  #endif
  int testcase=1;
  //cin>>testcase;
  for(int i=0;i<testcase;i++){
    SOLVE();
  }
  #ifdef LOCAL
  cerr<<"time:";
  cerr<<(clock()-start)/1000;
  cerr<<"ms\n";
  #endif
}
using R=long double;
constexpr R eps=1e-12;
constexpr R pi=3.141592653589793238;
struct Point{
  R x,y;
  Point(R x,R y):x(x),y(y){}
  Point():x(0),y(0){}
  friend Point operator+(const Point &a,const Point &b){return Point(a.x+b.x,a.y+b.y);}
  friend Point operator-(const Point &a,const Point &b){return Point(a.x-b.x,a.y-b.y);}
  friend Point operator*(const Point &a,const R &r){return Point(a.x*r,a.y*r);}
  friend Point operator/(const Point &a,const R &r){return Point(a.x/r,a.y/r);}
  Point &operator+=(const Point &a){
    *this=*this+a;
    return *this;
  }
  Point &operator-=(const Point &a){
    *this=*this-a;
    return *this;
  }
  Point &operator*=(const R &r){
    *this=*this*r;
    return *this;
  }
  Point &operator/=(const R &r){
    *this=*this/r;
    return *this;
  }
  friend bool operator==(const Point &a,const Point &b){return abs(a.x-b.x)<eps&&abs(a.y-b.y)<eps;}
  friend bool operator!=(const Point &a,const Point &b){return !(a==b);}
  friend istream &operator>>(istream &is,Point &a){
    is>>a.x>>a.y;
    return is;
  }
  friend ostream &operator<<(ostream &os,const Point &a){
    os<<a.x<<' '<<a.y;
    return os;
  }
  R arg()const{return atan2(y,x);}
  Point rot(R theta)const{
    R s=sin(theta),c=cos(theta);
    return Point(c*x-s*y,s*x+c*y);
  }
  R size()const{return sqrt(x*x+y*y);}
};
R dot(const Point &a,const Point &b){return a.x*b.x+a.y*b.y;}
R cross(const Point &a,const Point &b){return a.x*b.y-a.y*b.x;}
R distance(const Point &a,const Point &b){return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}
struct Line{
  Point a,b;
  Line():a(Point(0,0)),b(Point(0,0)){}
  Line(Point a,Point b):a(a),b(b){}
  //Ax+By=C
  Line(R A,R B,R C){
    assert(abs(A)>=eps||abs(B)>=eps);
    if(abs(A)<eps)a=Point(0,C/B),b=Point(1,C/B);
    else if(abs(B)<eps)a=Point(C/A,0),b=Point(C/A,1);
    else a=Point(C/A,0),b=Point(0,C/B);
  }
};
Point projection(const Point &p,const Line &l){
  R t=dot(p-l.a,l.a-l.b)/((l.a.x-l.b.x)*(l.a.x-l.b.x)+(l.a.y-l.b.y)*(l.a.y-l.b.y));
  return l.a+(l.a-l.b)*t;
}
Point reflection(const Point &p,const Line &l){
  return p+(projection(p,l)-p)*2.0;
}
R distance(const Line &l,const Point &a){return (a-projection(a,l)).size();}
Line suityokunitoubunsenn(const Point &a,const Point &b){
  Point c=(a+b)*R(0.5);
  Point d=(a-c).rot(pi/2)+c;
  return Line(c,d);
}
Point crosspoint(const Line &a,const Line &b){
  R c=cross(a.b-a.a,b.b-b.a),d=cross(a.b-a.a,a.b-b.a);
  if(abs(c)<eps&&abs(d)<eps)return b.a;
  return b.a+(b.b-b.a)*d/c;
}
bool ON(const Point &a,const Point &b,const Point &p){
  if(a==p)return true;
  if(b==p)return true;
  if(cross(a-p,b-p)>=eps)return false;
  return dot(a-p,b-p)<0;
}
bool sameline(const Point &a,const Point &b,const Point &c){return abs(cross(b-a,c-a))<eps;}
struct Circle{
  Point p;
  R r;
  Circle():p(Point(0,0)),r(0){}
  Circle(const Point p,R r):p(p),r(r){}
  Circle(const Point &a,const Point &b,const Point &c){
    if(abs(cross(b-a,c-a))<eps){
      r=1e19;
    }
    else{
      Line x=suityokunitoubunsenn(a,b),y=suityokunitoubunsenn(a,c);
      p=crosspoint(x,y);
      r=distance(p,a);
    }
  }
  bool in(const Point &a){return distance(a,p)<=r+eps;}
};
bool iscross(const Circle &a,const Circle &b){
  if((a.p-b.p).size()+eps>a.r+b.r)return false;
  if((a.p-b.p).size()<abs(a.r-b.r)+eps)return false;
  return true;
}
pair<Point,Point>crosspoint(const Circle &c,const Line &l){
  Point pr=projection(c.p,l);
  Point e=(l.b-l.a)/(l.b-l.a).size();
  if(abs(distance(l,c.p)-c.r)<eps)return {pr,pr};
  Point a=pr-c.p;
  double b=sqrt(c.r*c.r-(a.x*a.x+a.y*a.y));
  return {pr-e*b,pr+e*b};
}
pair<Point,Point>crosspoint(const Circle &a,const Circle &b){
  R d=(a.p-b.p).size();
  R e=acos((a.r*a.r+d*d-b.r*b.r)/(2*a.r*d));
  R t=atan2(b.p.y-a.p.y,b.p.x-a.p.x);
  Point p1=a.p+Point(cos(t+e)*a.r,sin(t+e)*a.r);
  Point p2=a.p+Point(cos(t-e)*a.r,sin(t-e)*a.r);
  return make_pair(p1,p2);
}
void SOLVE(){
  int q;
  cin>>q;
  Point a,b,c;
  cin>>a>>b>>c;
  Circle ci(a,b,c);
  if(Circle((a+b)/2,distance(a,b)/2).in(c))ci=Circle((a+b)/2,distance(a,b)/2);
  if(Circle((b+c)/2,distance(b,c)/2).in(a))ci=Circle((b+c)/2,distance(b,c)/2);
  if(Circle((c+a)/2,distance(c,a)/2).in(b))ci=Circle((c+a)/2,distance(c,a)/2);
  while(q--){
    Point p;
    cin>>p;
    cout<<(ci.in(p)?"Yes":"No")<<endl;
  }
}
0