結果
| 問題 |
No.2602 Real Collider
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2024-01-14 02:22:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,532 bytes |
| コンパイル時間 | 316 ms |
| コンパイル使用メモリ | 45,004 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-28 01:55:56 |
| 合計ジャッジ時間 | 4,514 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 50 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2602.cc: No.2602 Real Collider - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const double DELTA = 1e-9;
/* typedef */
template <typename T>
struct Pt {
T x, y;
Pt() {}
Pt(T _x, T _y) : x(_x), y(_y) {}
Pt(const Pt<T> &p) : x(p.x), y(p.y) {}
Pt<T> operator+(const Pt<T> p) const { return Pt<T>(x + p.x, y + p.y); }
Pt<T> operator-() const { return Pt<T>(-x, -y); }
Pt<T> operator-(const Pt<T> p) const { return Pt<T>(x - p.x, y - p.y); }
Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
T dot(Pt<T> v) const { return x * v.x + y * v.y; }
T cross(Pt<T> v) const { return x * v.y - y * v.x; }
Pt<T> mid(const Pt<T> p) { return Pt<T>((x + p.x) / 2, (y + p.y) / 2); }
T d2() { return x * x + y * y; }
Pt<T> rot90() { return Pt<T>(-y, x); }
bool operator==(const Pt<T> pt) const { return x == pt.x && y == pt.y; }
bool operator<(const Pt<T> &pt) const {
return x < pt.x || (x == pt.x && y < pt.y);
}
};
typedef Pt<double> pt;
struct CL {
pt p;
double t0, t1;
CL() {}
CL(const pt& _p, double _t0, double _t1) : p(_p), t0(_t0), t1(_t1) {}
};
/* global variables */
pt readpt() {
int x, y;
scanf("%d%d", &x, &y);
return pt(x, y);
}
/* subroutines */
bool cross_lines(const pt& ap, const pt av, const pt& bp, const pt bv, CL& cl) {
double op01 = av.cross(bv);
//if (op01 == 0.0) return false; /* need to handle parallel?? */
if (op01 == 0.0) {
pt v = bp - ap;
if (v.cross(av) != 0.0) return false;
pt a1 = ap + av;
pt b1 = bp + bv;
return
((bp - ap).dot(b1 - ap) <= 0.0 ||
(bp - a1).dot(b1 - a1) <= 0.0 ||
(ap - bp).dot(a1 - bp) <= 0.0 ||
(ap - b1).dot(a1 - b1) <= 0.0);
}
pt v = bp - ap;
double op0 = v.cross(av);
double op1 = v.cross(bv);
double t0 = op1 / op01;
double t1 = op0 / op01;
cl.p = bv * t1 + bp;
cl.t0 = t0;
cl.t1 = t1;
return true;
//return (0.0 <= cl.t0 && cl.t0 <= 1.0 && 0.0 <= cl.t1 && cl.t1 <= 1.0);
}
/* main */
int main() {
int qn;
scanf("%d", &qn);
pt pa = readpt(), pb = readpt(), pc = readpt();
pt p0 = (pa + pb) / 2, p1 = (pa + pc) / 2;
pt v0 = (pb - pa).rot90(), v1 = (pc - pa).rot90();
CL cl;
cross_lines(p0, v0, p1, v1, cl);
pt cp = cl.p;
double rr = (pa - cp).d2();
while (qn--) {
pt pi = readpt();
if ((pi - cp).d2() <= rr + DELTA) puts("Yes");
else puts("No");
}
return 0;
}
tnakao0123