結果
| 問題 |
No.2602 Real Collider
|
| コンテスト | |
| ユーザー |
maeshun
|
| 提出日時 | 2024-01-13 13:40:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 4,928 bytes |
| コンパイル時間 | 4,321 ms |
| コンパイル使用メモリ | 253,696 KB |
| 最終ジャッジ日時 | 2025-02-18 19:41:16 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 WA * 69 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for(int i=0;i<(n);++i)
#define rep1(i, n) for(int i=1;i<=(n);i++)
#define ll long long
using mint = modint998244353;
using P = pair<ll,ll>;
using lb = long double;
using T = tuple<ll, ll, ll>;
#ifdef LOCAL
# include <debug_print.hpp>
# define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
# define dbg(...) (static_cast<void>(0))
#endif
template<typename T>
struct Matrix {
int h, w;
vector<vector<T>> d;
Matrix() {}
//初期化のときは Matrix<> a(h, w)
Matrix(int h, int w, T val=0): h(h), w(w), d(h, vector<T>(w,val)) {}
Matrix& unit() {
assert(h == w);
rep(i,h) d[i][i] = 1;
return *this;
}
const vector<T>& operator[](int i) const { return d[i];}
vector<T>& operator[](int i) { return d[i];}
Matrix operator*(const Matrix& a) const {
assert(w == a.h);
Matrix r(h, a.w);
rep(i,h)rep(k,w)rep(j,a.w) {
r[i][j] += d[i][k]*a[k][j];
}
return r;
}
//Matcix<> newa = a.pow(k)と使う
Matrix pow(long long t) const {
assert(h == w);
if (!t) return Matrix(h,h).unit();
if (t == 1) return *this;
Matrix r = pow(t>>1);
r = r*r;
if (t&1) r = r*(*this);
return r;
}
};
// Vector
// https://youtu.be/UWbGRhF3Ozw?t=9564
long double eps = 1e-12;
struct V {
long double x, y;
V(long double x=0, long double y=0): x(x), y(y) {}
V& operator+=(const V& v) { x += v.x; y += v.y; return *this;}
V operator+(const V& v) const { return V(*this) += v;}
V& operator-=(const V& v) { x -= v.x; y -= v.y; return *this;}
V operator-(const V& v) const { return V(*this) -= v;}
V& operator*=(long double s) { x *= s; y *= s; return *this;}
V operator*(long double s) const { return V(*this) *= s;}
V& operator/=(long double s) { x /= s; y /= s; return *this;}
V operator/(long double s) const { return V(*this) /= s;}
long double dot(const V& v) const { return x*v.x + y*v.y;}
long double cross(const V& v) const { return x*v.y - v.x*y;}
long double norm2() const { return x*x + y*y;}
long double norm() const { return sqrt(norm2());}
V normalize() const { return *this/norm();}
V rotate90() const { return V(y, -x);}
int ort() const { // orthant
if (abs(x) < eps && abs(y) < eps) return 0;
if (y > 0) return x>0 ? 1 : 2;
else return x>0 ? 4 : 3;
}
bool operator<(const V& v) const {
int o = ort(), vo = v.ort();
if (o != vo) return o < vo;
return cross(v) > 0;
}
};
istream& operator>>(istream& is, V& v) {
is >> v.x >> v.y; return is;
}
ostream& operator<<(ostream& os, const V& v) {
os<<"("<<v.x<<","<<v.y<<")"; return os;
}
//三点の外心、一直線の時{1e18,1e18}
V circumcenter(V &P1, V &P2, V &P3){
V P12 = P2 - P1;
V P13 = P3 - P1;
long double AB2 = P12.norm2();
long double AC2 = P13.norm2();
long double ABAC = P12.dot(P13);
long double EPS = 1.0E-12;
long double denominator = (AB2*AC2-ABAC*ABAC);
V ans;
if(denominator < EPS){
// fprintf(stderr, "Circumcenter Error\n");
return {1e18, 1e18};
}
long double x = 0.5*(AB2*AC2-AC2*ABAC)/denominator;
long double y = 0.5*(AB2*AC2-AB2*ABAC)/denominator;
ans = P12*x + P13*y + P1;
return ans;
}
int main()
{
int q;
cin >> q;
ll x1, y1, x2, y2, x3, y3;
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
ll r;
if((x2-x1)*(y3-y1) == (x3-x1)*(y2-y1)){
ll Mx = max(x1, max(x2,x3));
ll mx = min(x1, min(x2, x3));
ll My = max(y1,max(y2, y3));
ll my = min(y1,min(y2, y3));
r = (Mx-mx) * (Mx-mx) + (My-my)*(My-my);
ll xg = (mx+Mx);
ll yg = (my+My);
rep(i,q){
ll x, y;
cin >> x >> y;
x *= 2 ;
y *= 2 ;
ll R = (xg-x)*(xg-x) + (yg-y) * (yg-y);
if(R<=r) {
cout << "Yes" << "\n";
}
else{
cout << "No" << "\n";
}
}
}
else{
ll det = (x2-x1)*(y3-y1) - (x3-x1)*(y2-y1);
Matrix<ll> m(2,2);
m[1][1] = x2-x1;
m[0][1] = -y2+y1;
m[0][0] = y3-y1;
m[1][0] = -x3+x1;
Matrix<ll> f(2,1);
f[0][0] = x2*x2+y2*y2 - x1*x1-y1*y1;
f[1][0] = x3*x3+y3*y3 - x1*x1-y1*y1;
dbg(det);
Matrix<ll> e = m*f;
r = (e[0][0]-2*det*x1) * (e[0][0]-2*det*x1) + (e[1][0]-2*det*y1) * (e[1][0] - 2*det*y1);
dbg(e[0][0], e[1][0]);
dbg(r);
rep(i,q){
ll x, y;
cin >> x >> y;
x *= 2 *det;
y *= 2 *det;
ll R = (e[0][0]-x)*(e[0][0]-x) + (e[1][0]-y) * (e[1][0]-y);
dbg(R);
if(R<=r) {
cout << "Yes" << "\n";
}
else{
cout << "No" << "\n";
}
}
}
return 0;
}
maeshun