結果
| 問題 |
No.2564 衝突予測
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-12-02 16:08:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,430 bytes |
| コンパイル時間 | 2,253 ms |
| コンパイル使用メモリ | 205,256 KB |
| 最終ジャッジ日時 | 2025-02-18 05:13:07 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 9 |
ソースコード
#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;
}