結果
| 問題 | No.2564 衝突予測 | 
| コンテスト | |
| ユーザー |  tnakao0123 | 
| 提出日時 | 2023-12-03 23:59:41 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 62 ms / 2,000 ms | 
| コード長 | 1,192 bytes | 
| コンパイル時間 | 348 ms | 
| コンパイル使用メモリ | 41,800 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-26 22:24:30 | 
| 合計ジャッジ時間 | 2,094 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 9 | 
ソースコード
/* -*- coding: utf-8 -*-
 *
 * 2564.cc:  No.2564 衝突予測 - yukicoder
 */
#include<cstdio>
#include<algorithm>
 
using namespace std;
/* constant */
/* typedef */
/* global variables */
/* subroutines */
/* main */
int main() {
  int tn;
  scanf("%d", &tn);
  while (tn--) {
    int x0, y0, x1, y1;
    char s0[4], s1[4];
    scanf("%d%d%s%d%d%s", &x0, &y0, s0, &x1, &y1, s1);
    char c0 = s0[0], c1 = s1[0];
    
    if ((y0 == y1 &&
	 ((x0 < x1 && c0 == 'R' && c1 == 'L') ||
	  (x0 > x1 && c0 == 'L' && c1 == 'R'))) ||
	(x0 == x1 &&
	 ((y0 < y1 && c0 == 'U' && c1 == 'D') ||
	  (y0 > y1 && c0 == 'D' && c1 == 'U'))))
      puts("Yes");
    else if ((c0 == 'L' || c0 == 'R') && (c1 == 'U' || c1 == 'D')) {
      int d0 = (c0 == 'L') ? x0 - x1 : x1 - x0;
      int d1 = (c1 == 'U') ? y0 - y1 : y1 - y0;
      if (d0 > 0 && d1 > 0 && d0 == d1) puts("Yes");
      else puts("No");
    }
    else if ((c0 == 'U' || c0 == 'D') && (c1 == 'L' || c1 == 'R')) {
      int d0 = (c0 == 'D') ? y0 - y1 : y1 - y0;
      int d1 = (c1 == 'R') ? x0 - x1 : x1 - x0;
      if (d0 > 0 && d1 > 0 && d0 == d1) puts("Yes");
      else puts("No");
    }
    else
      puts("No");
  }
  return 0;
}
            
            
            
        