結果
問題 | No.2564 衝突予測 |
ユーザー |
|
提出日時 | 2023-12-02 16:34:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 351 ms / 2,000 ms |
コード長 | 1,694 bytes |
コンパイル時間 | 2,318 ms |
コンパイル使用メモリ | 199,560 KB |
最終ジャッジ日時 | 2025-02-18 05:30:52 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 |
ソースコード
#include <bits/stdc++.h> //#include<atcoder/all> using namespace std; //using namespace atcoder; using ll = long long; const int INF = 1000000007; //const ll mod = 998244353; int t, x[100009][5], y[100009][5]; char d[100009][5]; int main() { cin >> t; for (int i = 1; i <= t; i++) { for (int j = 1; j <= 2; j++)cin >> x[i][j] >> y[i][j] >> d[i][j]; } for (int i = 1; i <= t; i++) { if (d[i][1] == d[i][2]) { cout << "No" << endl; continue; } set<char>S; S.insert(d[i][1]); S.insert(d[i][2]); if ((S.count('R') == 1 && S.count('L') == 1) || (S.count('U') == 1 && S.count('D') == 1)) { if (S.count('R') == 1) { if (y[i][1] == y[i][2]) { if (d[i][1] == 'L') { if (x[i][1] > x[i][2])cout << "Yes" << endl; else cout << "No" << endl; } if (d[i][2] == 'L') { if (x[i][2] > x[i][1])cout << "Yes" << endl; else cout << "No" << endl; } } else cout << "No" << endl; } if (S.count('U') == 1) { if (x[i][1] == x[i][2]) { if (d[i][1] == 'U') { if (y[i][1] < y[i][2])cout << "Yes" << endl; else cout << "No" << endl; } if (d[i][2] == 'U') { if (y[i][2] < y[i][1])cout << "Yes" << endl; else cout << "No" << endl; } } else cout << "No" << endl; } continue; } if (d[i][1] == 'R' || d[i][1] == 'L') { swap(d[i][1], d[i][2]); swap(x[i][1], x[i][2]); swap(y[i][1], y[i][2]); } int x1 = x[i][1], y2 = y[i][2]; int d1 = 0, d2 = 0; if (d[i][1] == 'U')d1 = y2 - y[i][1]; else d1 = y[i][1] - y2; if (d[i][2] == 'L')d2 = x[i][2] - x1; else d2 = x1 - x[i][2]; if (d1 == d2 && d1 > 0)cout << "Yes" << endl; else cout << "No" << endl; } }