結果
問題 | No.2564 衝突予測 |
ユーザー | hanage |
提出日時 | 2023-12-02 16:08:12 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,430 bytes |
コンパイル時間 | 2,451 ms |
コンパイル使用メモリ | 212,856 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-26 19:52:04 |
合計ジャッジ時間 | 6,733 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 3 ms
5,376 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while (T--) { long long x1, y1; char d1; cin >> x1 >> y1 >> d1; long long x2, y2; char d2; cin >> x2 >> y2 >> d2; string S; S += d1; S += d2; map<char, long long> mp; mp['R'] = 1; mp['L'] = -1; mp['U'] = 1; mp['D'] = -1; if (S == "RL" || S == "LR") { if (y1 == y2) { if (x1 < x2) { if (d1 == 'R' && d2 == 'L') { cout << "Yes" << endl; continue; } } else { if (d1 == 'L' && d2 == 'R') { cout << "Yes" << endl; continue; } } } } if (S == "UD" || S == "DU") { if (x1 == x2) { if (y1 < y2) { if (d1 == 'U' && d2 == 'D') { cout << "Yes" << endl; continue; } } else { if (d1 == 'D' && d2 == 'U') { cout << "Yes" << endl; continue; } } } } if (S == "RL" || S == "LR") { long long l = min(x1, x2), r = max(x1, x2); long long mid = l + (r - l) / 2; long long dx1 = abs(x1 - mid); // long long dx2 = abs(x2 - mid); x1 = x1 + dx1 * mp[d1]; x2 = x2 + dx1 * mp[d2]; if (x1 == x2 && y1 == y2) { cout << "Yes" << endl; continue; } } if (S == "UD" || S == "DU") { long long l = min(y1, y2), r = max(y1, y2); long long mid = l + (r - l) / 2; long long dy1 = abs(y1 - mid); // long long dy2 = abs(y2 - mid); y1 = y1 + dy1 * mp[d1]; y2 = y2 + dy1 * mp[d2]; if (x1 == x2 && y1 == y2) { cout << "Yes" << endl; continue; } } if (S == "RU" || S == "RD" || S == "LU" || S == "LD") { long long xx = x2, yy = y1; long long dx = abs(x1 - xx); long long dy = abs(y2 - yy); x1 = x1 + dx * mp[d1]; y2 = y2 + dy * mp[d2]; if (x1 == x2 && y1 == y2) { cout << "Yes" << endl; continue; } } if (S == "UR" || S == "UL" || S == "DR" || S == "DL") { long long xx = x1, yy = y2; long long dx = abs(x2 - xx); long long dy = abs(y1 - yy); x2 = x2 + dx * mp[d2]; y1 = y1 + dy * mp[d1]; if (x1 == x2 && y1 == y2) { cout << "Yes" << endl; continue; } } cout << "No" << endl; } return 0; }