結果
| 問題 |
No.2564 衝突予測
|
| コンテスト | |
| ユーザー |
norikame
|
| 提出日時 | 2023-12-03 23:16:03 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 347 ms / 2,000 ms |
| コード長 | 1,294 bytes |
| コンパイル時間 | 4,191 ms |
| コンパイル使用メモリ | 253,048 KB |
| 最終ジャッジ日時 | 2025-02-18 06:57:44 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
//
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()
const int INF = (int)(1e9);
const vector<char> clst = { 'R', 'U', 'L', 'D' };
void r_roll(int& x1, int& y1, int& di1, int& x2, int& y2, int& di2) {
swap(x1, y1), swap(x2, y2);
y1 *= -1, y2 *= -1;
di1 = (di1+3) % 4, di2 = (di2+3) % 4;
}
int main() {
int t0;
cin >> t0;
rep(i0, t0) {
int x1, y1, x2, y2;
char d1, d2;
cin >> x1 >> y1 >> d1 >> x2 >> y2 >> d2;
int di1 = find(all(clst), d1) - clst.begin(), di2 = find(all(clst), d2) - clst.begin(), rlen = di1;
rep(i, rlen) r_roll(x1, y1, di1, x2, y2, di2);
if (di2 == 0) cout << "No" << endl;
else if (di2 == 1) {
if (x2 > x1 && x2-x1 == y1-y2) cout << "Yes" << endl;
else cout << "No" << endl;
}
else if (di2 == 2) {
if (y1 == y2 && x2 > x1) cout << "Yes" << endl;
else cout << "No" << endl;
}
else {
if (x2 > x1 && x2-x1 == y2-y1) cout << "Yes" << endl;
else cout << "No" << endl;
}
}
return 0;
}
norikame