結果

問題 No.2564 衝突予測
ユーザー kwm_tkwm_t
提出日時 2023-12-02 17:00:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,215 bytes
コンパイル時間 2,434 ms
コンパイル使用メモリ 201,904 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2023-12-02 17:00:51
合計ジャッジ時間 4,013 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
int calc(int x, int y, int p, int q, char d) {
	if (x != p && y != q)return -1;
	if (x == p) {
		if (y <= q && d == 'U') {
			return abs(y - q);
		}
		if (y >= q && d == 'D') {
			return abs(y - q);
		}
	}
	if (y == q) {
		if (x <= p && d == 'R') {
			return abs(x - p);
		}
		if (x >= p && d == 'L') {
			return abs(x - p);
		}
	}
	return -1;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int t; cin >> t;
	while (t--) {
		int x0, y0;
		char d0;
		cin >> x0 >> y0 >> d0;
		int x1, y1;
		char d1;
		cin >> x1 >> y1 >> d1;
		if (d0 == d1) {
			cout << "No" << endl;
			continue;
		}
		if (x0 == x1) {
			if (y0 > y1) {
				swap(y0, y1);
				swap(d0, d1);
			}
			if (d0 == 'U' && d1 == 'D') cout << "Yes" << endl;
			else cout << "No" << endl;
			continue;
		}
		if (y0 == y1) {
			if (x0 > x1) {
				swap(x0, x1);
				swap(d0, d1);
			}
			if (d0 == 'R' && d1 == 'L') cout << "Yes" << endl;
			continue;
		}
		{
			int x2 = x0;
			int y2 = y1;
			auto f0 = calc(x0, y0, x2, y2, d0);
			auto f1 = calc(x1, y1, x2, y2, d1);
			if (-1 != f0 && -1 != f1 && f0 == f1) {
				cout << "Yes" << endl;
				continue;
			}
		}
		{
			int x2 = x1;
			int y2 = y0;
			auto f0 = calc(x0, y0, x2, y2, d0);
			auto f1 = calc(x1, y1, x2, y2, d1);
			if (-1 != f0 && -1 != f1 && f0 == f1) {
				cout << "Yes" << endl;
				continue;
			}
		}
		cout << "No" << endl;
	}
	return 0;
}
0