結果

問題 No.2564 衝突予測
ユーザー norikamenorikame
提出日時 2023-12-03 23:16:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 328 ms / 2,000 ms
コード長 1,294 bytes
コンパイル時間 4,953 ms
コンパイル使用メモリ 264,652 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-03 23:16:13
合計ジャッジ時間 9,891 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 328 ms
6,676 KB
testcase_04 AC 322 ms
6,676 KB
testcase_05 AC 322 ms
6,676 KB
testcase_06 AC 322 ms
6,676 KB
testcase_07 AC 325 ms
6,676 KB
testcase_08 AC 320 ms
6,676 KB
testcase_09 AC 321 ms
6,676 KB
testcase_10 AC 319 ms
6,676 KB
testcase_11 AC 321 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 

#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;
}
0