結果
問題 | No.2564 衝突予測 |
ユーザー |
|
提出日時 | 2023-12-02 15:30:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 177 ms / 2,000 ms |
コード長 | 1,851 bytes |
コンパイル時間 | 1,955 ms |
コンパイル使用メモリ | 99,548 KB |
最終ジャッジ日時 | 2025-02-18 04:40:36 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 |
ソースコード
#include <iostream> #include <iomanip> #include <vector> #include <algorithm> #include <utility> #include <string> #include <queue> #include <stack> #include <unordered_set> #include <unordered_map> using namespace std; typedef long long int ll; typedef pair<int, int> Pii; const ll mod = 998244353; struct problem { int x1, y1; char d1; int x2, y2; char d2; }; int main() { cin.tie(0); ios::sync_with_stdio(false); int t; cin >> t; vector<problem> problems(t); for (auto &p: problems) { cin >> p.x1 >> p.y1 >> p.d1; cin >> p.x2 >> p.y2 >> p.d2; } vector<string> ans(t); for (int i = 0; i < t; i++) { auto p = problems[i]; if (p.d1 == p.d2) { ans[i] = "No"; } else if (p.d1 == 'R' && p.d2 == 'L') { ans[i] = (p.y1 == p.y2 && p.x1 < p.x2) ? "Yes" : "No"; } else if (p.d1 == 'L' && p.d2 == 'R') { ans[i] = (p.y1 == p.y2 && p.x1 > p.x2) ? "Yes" : "No"; } else if (p.d1 == 'U' && p.d2 == 'D') { ans[i] = (p.x1 == p.x2 && p.y1 < p.y2) ? "Yes" : "No"; } else if (p.d1 == 'D' && p.d2 == 'U') { ans[i] = (p.x1 == p.x2 && p.y1 > p.y2) ? "Yes" : "No"; } else if ((p.d1 == 'R' && p.d2 == 'U') || (p.d1 == 'D' && p.d2 == 'L')) { ans[i] = (p.x1 + p.y1 == p.x2 + p.y2 && p.x1 < p.x2) ? "Yes" : "No"; } else if ((p.d1 == 'L' && p.d2 == 'D') || (p.d1 == 'U' && p.d2 == 'R')) { ans[i] = (p.x1 + p.y1 == p.x2 + p.y2 && p.x1 > p.x2) ? "Yes" : "No"; } else if ((p.d1 == 'R' && p.d2 == 'D') || (p.d1 == 'U' && p.d2 == 'L')) { ans[i] = (p.x1 - p.y1 == p.x2 - p.y2 && p.x1 < p.x2) ? "Yes" : "No"; } else if ((p.d1 == 'L' && p.d2 == 'U') || (p.d1 == 'D' && p.d2 == 'R')) { ans[i] = (p.x1 - p.y1 == p.x2 - p.y2 && p.x1 > p.x2) ? "Yes" : "No"; } } for (auto &x: ans) cout << x << endl; return 0; }