結果
| 問題 | No.2564 衝突予測 |
| コンテスト | |
| ユーザー |
shisidor
|
| 提出日時 | 2023-12-02 18:19:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 321 ms / 2,000 ms |
| コード長 | 1,868 bytes |
| 記録 | |
| コンパイル時間 | 514 ms |
| コンパイル使用メモリ | 64,128 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-26 21:22:22 |
| 合計ジャッジ時間 | 4,718 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
#include<iostream>
using namespace std;
int main() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
int x1, x2, y1, y2;
char d1, d2;
cin >> x1 >> y1 >> d1 >> x2 >> y2 >> d2;
bool res;
if (d1 == d2) res = false;
else if (d1 == 'R' && d2 == 'L') {
if (x1 < x2 && y1 == y2) res = true;
else res = false;
}
else if (d1 == 'L' && d2 == 'R') {
if (x1 > x2 && y1 == y2) res = true;
else res = false;
}
else if (d1 == 'U' && d2 == 'D') {
if (y1 < y2 && x1 == x2) res = true;
else res = false;
}
else if (d1 == 'D' && d2 == 'U') {
if (y1 > y2 && x1 == x2) res = true;
else res = false;
}
else {
if (d1 == 'R') {
int d;
if (d2 == 'U') d = 1;
else d = -1;
if (x2 - x1 > 0 && x2 - x1 == d * (y1 - y2)) res = true;
else res = false;
}
else if (d1 == 'L') {
int d;
if (d2 == 'U') d = 1;
else d = -1;
if (x2 - x1 < 0 && x1 - x2 == d * (y1 - y2)) res = true;
else res = false;
}
else if (d1 == 'U') {
int d = 0;
if (d2 == 'L') d = -1;
else d = 1;
if (y2 - y1 > 0 && y2 - y1 == d * (x1 - x2)) res = true;
else res = false;
}
else {
int d = 0;
if (d2 == 'L') d = -1;
else d = 1;
if (y2 - y1 < 0 && y1 - y2 == d * (x1 - x2)) res = true;
else res = false;
}
}
if (res) cout << "Yes" << endl;
else cout << "No" << endl;
}
}
shisidor