結果
| 問題 | No.2564 衝突予測 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-12-02 16:17:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,799 bytes |
| 記録 | |
| コンパイル時間 | 2,052 ms |
| コンパイル使用メモリ | 194,576 KB |
| 最終ジャッジ日時 | 2025-02-18 05:19:57 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int index(char dir)
{
if (dir == 'R')
return 0;
else if (dir == 'U')
return 1;
else if (dir == 'L')
return 2;
else
return 3;
}
int main()
{
int T;
cin >> T;
for (int t = 0; t < T; t++)
{
// input
int x1, x2, y1, y2;
char d1, d2;
cin >> x1 >> y1 >> d1;
cin >> x2 >> y2 >> d2;
// main
string ans;
if (x1 == x2)
{
if (y1 < y2 && d1 == 'U' && d2 == 'D' && abs(y1 - y2) % 2 == 0)
ans = "Yes";
else if (y1 > y2 && d1 == 'D' && d2 == 'U' && abs(y1 - y2) % 2 == 0)
ans = "Yes";
else
ans = "No";
}
else if (y1 == y2)
{
if (x1 < x2 && d1 == 'R' && d2 == 'L')
ans = "Yes";
else if (x1 > x2 && d1 == 'L' && d2 == 'R')
ans = "Yes";
else
ans = "No";
}
else
{
int d_idx1 = index(d1), d_idx2 = index(d2);
int t1 = abs(x1 - x2), t2 = abs(y1 - y2);
if (t1 == t2)
{
int cx1, cx2, cy1, cy2;
cx1 = x1 + t1 * dx[d_idx1];
cy1 = y1 + t2 * dy[d_idx1];
cx2 = x2 + t1 * dx[d_idx2];
cy2 = y2 + t2 * dy[d_idx2];
// cout << cx1 << ", " << cy1 << endl;
// cout << cx2 << ", " << cy2 << endl;
if (cx1 == cx2 && cy1 == cy2)
ans = "Yes";
else
ans = "No";
}
}
// output
cout << ans << endl;
}
}