結果

問題 No.2564 衝突予測
ユーザー tnakao0123tnakao0123
提出日時 2023-12-03 23:55:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,152 bytes
コンパイル時間 1,135 ms
コンパイル使用メモリ 41,408 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-03 23:55:40
合計ジャッジ時間 2,294 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 63 ms
6,676 KB
testcase_04 AC 62 ms
6,676 KB
testcase_05 AC 61 ms
6,676 KB
testcase_06 AC 60 ms
6,676 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- 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 == 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 == d1) puts("Yes");
      else puts("No");
    }
    else
      puts("No");
  }

  return 0;
}
0