結果

問題 No.2564 衝突予測
ユーザー may17may17
提出日時 2023-12-02 16:34:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 318 ms / 2,000 ms
コード長 1,694 bytes
コンパイル時間 2,757 ms
コンパイル使用メモリ 209,460 KB
実行使用メモリ 7,880 KB
最終ジャッジ日時 2023-12-02 16:35:03
合計ジャッジ時間 5,948 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 300 ms
7,880 KB
testcase_04 AC 318 ms
7,880 KB
testcase_05 AC 296 ms
7,880 KB
testcase_06 AC 301 ms
7,880 KB
testcase_07 AC 289 ms
7,880 KB
testcase_08 AC 311 ms
7,880 KB
testcase_09 AC 297 ms
7,880 KB
testcase_10 AC 304 ms
7,880 KB
testcase_11 AC 296 ms
7,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
const int INF = 1000000007;
//const ll mod = 998244353;
int t, x[100009][5], y[100009][5];
char d[100009][5];
int main() {
	cin >> t;
	for (int i = 1; i <= t; i++) {
		for (int j = 1; j <= 2; j++)cin >> x[i][j] >> y[i][j] >> d[i][j];
	}
	for (int i = 1; i <= t; i++) {
		if (d[i][1] == d[i][2]) {
			cout << "No" << endl;
			continue;
		}
		set<char>S;
		S.insert(d[i][1]);
		S.insert(d[i][2]);
		if ((S.count('R') == 1 && S.count('L') == 1) || (S.count('U') == 1 && S.count('D') == 1)) {
			if (S.count('R') == 1) {
				if (y[i][1] == y[i][2]) {
					if (d[i][1] == 'L') {
						if (x[i][1] > x[i][2])cout << "Yes" << endl;
						else cout << "No" << endl;
					}
					if (d[i][2] == 'L') {
						if (x[i][2] > x[i][1])cout << "Yes" << endl;
						else cout << "No" << endl;
					}
				}
				else cout << "No" << endl;
			}
			if (S.count('U') == 1) {
				if (x[i][1] == x[i][2]) {
					if (d[i][1] == 'U') {
						if (y[i][1] < y[i][2])cout << "Yes" << endl;
						else cout << "No" << endl;
					}
					if (d[i][2] == 'U') {
						if (y[i][2] < y[i][1])cout << "Yes" << endl;
						else cout << "No" << endl;
					}
				}
				else cout << "No" << endl;
			}
			continue;
		}
		if (d[i][1] == 'R' || d[i][1] == 'L') {
			swap(d[i][1], d[i][2]);
			swap(x[i][1], x[i][2]);
			swap(y[i][1], y[i][2]);
		}
		int x1 = x[i][1], y2 = y[i][2];
		int d1 = 0, d2 = 0;
		if (d[i][1] == 'U')d1 = y2 - y[i][1];
		else d1 = y[i][1] - y2;
		if (d[i][2] == 'L')d2 = x[i][2] - x1;
		else d2 = x1 - x[i][2];
		if (d1 == d2 && d1 > 0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}
0