結果
問題 |
No.2564 衝突予測
|
ユーザー |
![]() |
提出日時 | 2024-09-18 04:07:00 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 428 ms / 2,000 ms |
コード長 | 945 bytes |
コンパイル時間 | 3,117 ms |
コンパイル使用メモリ | 254,700 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-18 04:07:10 |
合計ジャッジ時間 | 9,241 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ld = long double; using P = pair<ld, ld>; int main() { int t; cin >> t; auto calc = [&](P p, P q, P r, P s) { auto [a, c] = p; auto [b, d] = q; auto [e, g] = r; auto [f, h] = s; if (b == f && d == h) { return a == e && c == g; } else if (b == f) { return a == e && (c - g) / (h - d) > 0; } else if (d == h) { return c == g && (a - e) / (f - b) > 0; } else { return (a - e) / (f - b) > 0 && ((a - e) / (f - b)) == ((c - g) / (h - d)); } }; map<char, P> mp; mp['R'] = {1, 0}; mp['L'] = {-1, 0}; mp['U'] = {0, 1}; mp['D'] = {0, -1}; while (t--) { ld x1, y1, x2, y2; char d1, d2; cin >> x1 >> y1 >> d1 >> x2 >> y2 >> d2; cout << (calc({x1, y1}, mp[d1], {x2, y2}, mp[d2]) ? "Yes" : "No") << endl; } }