結果
| 問題 |
No.2628 Shrinkage
|
| コンテスト | |
| ユーザー |
nono00
|
| 提出日時 | 2024-02-16 22:43:42 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,188 bytes |
| コンパイル時間 | 8,200 ms |
| コンパイル使用メモリ | 444,640 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-09-28 21:20:43 |
| 合計ジャッジ時間 | 8,984 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 27 |
ソースコード
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
using Real = boost::rational<boost::multiprecision::cpp_int>;
struct Point {
Point() {}
Real x = 0, y = 0;
};
bool operator==(Point lhs, Point rhs) {
return lhs.x == rhs.x && lhs.y == rhs.y;
}
struct Line {
Real m, c;
bool valid = true;
Line() {}
Line(Point lhs, Point rhs) {
if (lhs.x - rhs.x == 0) {
valid = false;
m = lhs.x;
} else {
m = (lhs.y - rhs.y) / (lhs.x - rhs.x);
c = lhs.y - m * lhs.x;
}
}
auto operator<=>(const Line& lhs) const = default;
};
std::pair<bool, Point> intersect(Line lhs, Line rhs) {
if (!lhs.valid && !rhs.valid) return {false, Point()};
if (!lhs.valid) {
Point p;
p.x = lhs.m;
p.y = rhs.m * p.x + rhs.c;
return {true, p};
} else if (!rhs.valid) {
Point p;
p.x = rhs.m;
p.y = lhs.m * p.x + lhs.c;
return {true, p};
}
if (lhs.m == rhs.m) return {false, Point()};
Point p;
p.x = (lhs.c - rhs.c) / (rhs.m - lhs.m);
p.y = lhs.m * p.x + lhs.c;
return {true, p};
}
Real dist(Point lhs, Point rhs) {
return (lhs.x - rhs.x) * (lhs.x - rhs.x) + (lhs.y - rhs.y) * (lhs.y - rhs.y);
}
void solve() {
std::vector<Point> points(4);
for (int i = 0; i < 4; i++) {
long long x, y;
std::cin >> x >> y;
points[i].x = x;
points[i].y = y;
}
if (points[0] == points[2] && points[1] == points[3]) {
std::cout << "Yes" << '\n';
return;
}
if (dist(points[0], points[1]) <= dist(points[2], points[3])) {
std::cout << "No" << '\n';
return;
}
Line l1(points[0], points[1]);
Line l2(points[2], points[3]);
bool ok = false;
if (!l1.valid && !l2.valid) {
ok = true;
} else if (l1.valid && l2.valid) {
ok = l1.m == l2.m;
}
std::cout << (ok ? "Yes" : "No") << '\n';
}
int main() {
std::cin.tie(0)->sync_with_stdio(0);
std::cout << std::fixed << std::setprecision(16);
int t = 1;
std::cin >> t;
while (t--) solve();
}
nono00