結果
問題 | No.2602 Real Collider |
ユーザー | nono00 |
提出日時 | 2024-01-13 00:52:53 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,494 bytes |
コンパイル時間 | 7,948 ms |
コンパイル使用メモリ | 449,460 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-28 00:54:04 |
合計ジャッジ時間 | 30,809 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 916 ms
5,376 KB |
testcase_11 | AC | 274 ms
5,376 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 206 ms
5,376 KB |
testcase_16 | AC | 316 ms
5,376 KB |
testcase_17 | AC | 354 ms
5,376 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 409 ms
5,376 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 189 ms
5,376 KB |
testcase_27 | WA | - |
testcase_28 | AC | 316 ms
5,376 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 325 ms
5,376 KB |
testcase_32 | AC | 272 ms
5,376 KB |
testcase_33 | AC | 323 ms
5,376 KB |
testcase_34 | AC | 313 ms
5,376 KB |
testcase_35 | AC | 203 ms
5,376 KB |
testcase_36 | AC | 183 ms
5,376 KB |
testcase_37 | AC | 359 ms
5,376 KB |
testcase_38 | AC | 360 ms
5,376 KB |
testcase_39 | AC | 377 ms
5,376 KB |
testcase_40 | AC | 172 ms
5,376 KB |
testcase_41 | AC | 405 ms
5,376 KB |
testcase_42 | AC | 304 ms
5,376 KB |
testcase_43 | AC | 301 ms
5,376 KB |
testcase_44 | AC | 418 ms
5,376 KB |
testcase_45 | AC | 247 ms
5,376 KB |
testcase_46 | AC | 243 ms
5,376 KB |
testcase_47 | AC | 370 ms
5,376 KB |
testcase_48 | AC | 265 ms
5,376 KB |
testcase_49 | AC | 237 ms
5,376 KB |
testcase_50 | AC | 174 ms
5,376 KB |
testcase_51 | AC | 192 ms
5,376 KB |
testcase_52 | AC | 131 ms
5,376 KB |
testcase_53 | AC | 342 ms
5,376 KB |
testcase_54 | AC | 258 ms
5,376 KB |
testcase_55 | AC | 289 ms
5,376 KB |
testcase_56 | AC | 289 ms
5,376 KB |
testcase_57 | AC | 266 ms
5,376 KB |
testcase_58 | AC | 96 ms
5,376 KB |
testcase_59 | AC | 314 ms
5,376 KB |
testcase_60 | AC | 258 ms
5,376 KB |
testcase_61 | AC | 212 ms
5,376 KB |
testcase_62 | AC | 326 ms
5,376 KB |
testcase_63 | AC | 362 ms
5,376 KB |
testcase_64 | AC | 440 ms
5,376 KB |
testcase_65 | AC | 213 ms
5,376 KB |
testcase_66 | AC | 354 ms
5,376 KB |
testcase_67 | AC | 157 ms
5,376 KB |
testcase_68 | AC | 189 ms
5,376 KB |
testcase_69 | AC | 125 ms
5,376 KB |
testcase_70 | AC | 155 ms
5,376 KB |
testcase_71 | AC | 207 ms
5,376 KB |
testcase_72 | AC | 315 ms
5,376 KB |
testcase_73 | AC | 260 ms
5,376 KB |
testcase_74 | AC | 342 ms
5,376 KB |
testcase_75 | AC | 350 ms
5,376 KB |
testcase_76 | AC | 308 ms
5,376 KB |
testcase_77 | AC | 308 ms
5,376 KB |
testcase_78 | AC | 405 ms
5,376 KB |
testcase_79 | AC | 322 ms
5,376 KB |
testcase_80 | AC | 377 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> #include <boost/multiprecision/cpp_int.hpp> #include <boost/rational.hpp> using BigInt = boost::multiprecision::cpp_int; using Rational = boost::rational<BigInt>; const BigInt INF = 1LL << 62; struct Point { Point() {} Point(Rational x, Rational y): x(x), y(y) {} Rational x, y; }; Point mid_point(Point lhs, Point rhs) { return Point((lhs.x + rhs.x) / 2, (lhs.y + rhs.y) / 2); } const Rational UNDEF(INF); struct Line { Rational coef; Rational constant; Line() {} Line(Rational coe, Rational con): coef(coe), constant(con) {} Line(Rational coef, Point point): coef(coef), constant(point.y - point.x * coef) {} }; Rational distance(Point lhs, Point rhs) { return (lhs.x - rhs.x) * (lhs.x - rhs.x) + (lhs.y - rhs.y) * (lhs.y - rhs.y); } struct Circle { Point center; Rational radius; Circle(Point p, Rational r): center(p), radius(r) {} }; bool inside(Circle circle, Point point) { return distance(circle.center, point) <= circle.radius; } void solve() { int q; std::cin >> q; std::vector<Point> points(3); for (int i = 0; i < 3; i++) { int x, y; std::cin >> x >> y; points[i] = Point(Rational(x), Rational(y)); } std::vector<Line> lines(2); for (int i = 0; i < 2; i++) { if (points[i].y == points[i + 1].y) { Point mid = mid_point(points[i], points[i + 1]); lines[i] = Line(UNDEF, mid.x); } else { Rational coef = (points[i + 1].x - points[i].x) / (points[i].y - points[i + 1].y); Point mid = mid_point(points[i], points[i + 1]); lines[i] = Line(coef, mid); } } Point center; if (lines[0].coef == lines[1].coef) { Rational min_dist = UNDEF; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 3; j++) { Point mid = mid_point(points[i], points[j]); Rational dist(0); for (int k = 0; k < 3; k++) { Rational d = distance(mid, points[k]); if (dist < d) { dist = d; } } if (dist < min_dist) { min_dist = dist; center = mid; } } } } else { if (lines[0].coef == UNDEF || lines[1].coef == UNDEF) { if (lines[0].coef == UNDEF) std::swap(lines[0], lines[1]); center.x = lines[1].constant; center.y = lines[0].coef * center.x + lines[0].constant; } else { center.x = (lines[1].constant - lines[0].constant) / (lines[0].coef - lines[1].coef); center.y = (lines[0].coef * lines[1].constant - lines[0].constant * lines[1].coef) / (lines[0].coef - lines[1].coef); } Rational d = distance(points[0], center); for (int i = 1; i < 3; i++) {} } Rational radius = 0; for (int i = 0; i < 3; i++) { Rational r = distance(center, points[i]); if (radius < r) { radius = r; } } Circle circle(center, radius); while (q--) { int x, y; std::cin >> x >> y; Point p(x, y); std::cout << (inside(circle, p) ? "Yes" : "No") << '\n'; } } int main() { std::cin.tie(0)->sync_with_stdio(0); std::cout << std::fixed << std::setprecision(16); int t = 1; while (t--) solve(); }