結果

問題 No.2564 衝突予測
ユーザー forest3forest3
提出日時 2024-01-06 02:53:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 320 ms / 2,000 ms
コード長 1,607 bytes
コンパイル時間 2,040 ms
コンパイル使用メモリ 169,444 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-06 02:53:59
合計ジャッジ時間 7,036 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for( ll i = 0; i < n; i++ )
using ll = long long;

int main() {
	int T;
	cin >> T;
	int x1, y1, x2, y2;
	char d1, d2;
	rep(i, T) {
		cin >> x1 >> y1 >> d1 >> x2 >> y2 >> d2;
		string ans = "No";
		if( d1 == 'R' && d2 == 'L' ) {
			if(y1 == y2 && x1 < x2 ) ans = "Yes";
		}
		if( d1 == 'L' && d2 == 'R' ) {
			if(y1 == y2 && x2 < x1 ) ans = "Yes";
		}
		if(d1 == 'D' && d2 == 'U') {
			if(x1 == x2 && y1 > y2)  ans = "Yes";
		}
		if(d1 == 'U' && d2 == 'D') {
			if(x1 == x2 && y2 > y1)  ans = "Yes";
		}
		if(d1 == 'R' && d2 == 'U') {
			int dx = x2 - x1;
			int dy = y1 - y2;
			if(dx > 0 && dy > 0 && dx == dy) ans = "Yes";
		}
		if(d2 == 'R' && d1 == 'U') {
			int dx = x1 - x2;
			int dy = y2 - y1;
			if(dx > 0 && dy > 0 && dx == dy) ans = "Yes";
		}
		if(d1 == 'R' && d2 == 'D') {
			int dx = x2 - x1;
			int dy = y1 - y2;
			if(dx > 0 && dy < 0 && dx == -dy) ans = "Yes";
		}
		if(d2 == 'R' && d1 == 'D') {
			int dx = x1 - x2;
			int dy = y2 - y1;
			if(dx > 0 && dy < 0 && dx == -dy) ans = "Yes";
		}
		if(d1 == 'L' && d2 == 'U') {
			int dx = x2 - x1;
			int dy = y1 - y2;
			if(dx < 0 && dy > 0 && -dx == dy) ans = "Yes";
		}
		if(d2 == 'L' && d1 == 'U') {
			int dx = x1 - x2;
			int dy = y2 - y1;
			if(dx < 0 && dy > 0 && -dx == dy) ans = "Yes";
		}
		if(d1 == 'L' && d2 == 'D') {
			int dx = x2 - x1;
			int dy = y1 - y2;
			if(dx < 0 && dy < 0 && dx == dy) ans = "Yes";
		}
		if(d2 == 'L' && d1 == 'D') {
			int dx = x1 - x2;
			int dy = y2 - y1;
			if(dx < 0 && dy < 0 && dx == dy) ans = "Yes";
		}
		cout << ans << endl;
	}
}
0