結果
問題 | No.2602 Real Collider |
ユーザー | cho435 |
提出日時 | 2024-01-12 23:16:37 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 936 ms / 2,000 ms |
コード長 | 1,812 bytes |
コンパイル時間 | 8,750 ms |
コンパイル使用メモリ | 520,064 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-28 00:00:04 |
合計ジャッジ時間 | 32,300 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 78 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> #include <boost/multiprecision/cpp_dec_float.hpp> #include <boost/multiprecision/cpp_int.hpp> #include <boost/rational.hpp> using namespace std; using ll = long long; #define rep(i,n) for(int i=0;i<(int)(n);i++) using mint = atcoder::modint998244353; namespace mp = boost::multiprecision; using Bint = mp::cpp_int; using ld = boost::rational<Bint>; int main(){ int q; cin>>q; vector<pair<int,int>> vp(3); vector<pair<int,int>> vq(q); for(auto&[x,y]:vp) cin>>x>>y; for(auto&[x,y]:vq) cin>>x>>y; ld cx,cy,r2=-1; rep(i,3){ int x1,x2,y1,y2; x1=vp.at(1).first-vp.at(0).first; x2=vp.at(2).first-vp.at(0).first; y1=vp.at(1).second-vp.at(0).second; y2=vp.at(2).second-vp.at(0).second; if(x1*x2+y1*y2<=0){ cx=(vp.at(1).first+vp.at(2).first); cy=(vp.at(1).second+vp.at(2).second); cx/=2; cy/=2; r2=(vp.at(1).first-vp.at(2).first)*(vp.at(1).first-vp.at(2).first) +(vp.at(1).second-vp.at(2).second)*(vp.at(1).second-vp.at(2).second); r2/=4; break; } swap(vp.at(0),vp.at(1)); swap(vp.at(1),vp.at(2)); } if(r2<0){ ld k=0; k+=(vp.at(0).first-vp.at(2).first)*(vp.at(1).first-vp.at(2).first); k+=(vp.at(0).second-vp.at(2).second)*(vp.at(1).second-vp.at(2).second); ld dv=0; dv+=(vp.at(0).first-vp.at(2).first)*(vp.at(1).second-vp.at(2).second); dv-=(vp.at(0).second-vp.at(2).second)*(vp.at(1).first-vp.at(2).first); assert(abs(dv)>0); k/=dv; cx=(vp.at(0).first+vp.at(1).first)+k*(vp.at(0).second-vp.at(1).second); cx/=2; cy=(vp.at(0).second+vp.at(1).second)-k*(vp.at(0).first-vp.at(1).first); cy/=2; r2=(vp.at(0).first-cx)*(vp.at(0).first-cx)+(vp.at(0).second-cy)*(vp.at(0).second-cy); } for(auto[x,y]:vq){ ld d2=(x-cx)*(x-cx)+(y-cy)*(y-cy); if(d2<=r2) cout<<"Yes\n"; else cout<<"No\n"; } }