結果

問題 No.2564 衝突予測
ユーザー YuuuTYuuuT
提出日時 2023-12-02 15:41:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 206 ms / 2,000 ms
コード長 1,260 bytes
コンパイル時間 473 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,812 KB
最終ジャッジ日時 2023-12-02 15:41:26
合計ジャッジ時間 3,395 ms
ジャッジサーバーID
(参考情報)
judge9 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,588 KB
testcase_01 AC 38 ms
53,588 KB
testcase_02 AC 39 ms
53,588 KB
testcase_03 AC 158 ms
76,556 KB
testcase_04 AC 167 ms
76,444 KB
testcase_05 AC 160 ms
76,444 KB
testcase_06 AC 156 ms
76,428 KB
testcase_07 AC 159 ms
76,564 KB
testcase_08 AC 160 ms
76,444 KB
testcase_09 AC 195 ms
76,812 KB
testcase_10 AC 190 ms
76,812 KB
testcase_11 AC 206 ms
76,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,math
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def ms(): return map(int, input().split())
def li(): return list(map(int,input().split()))
#////////////////////////////////////
T = ii()
for _ in range(T):
  x1,y1,d1 = input().split()
  x2,y2,d2 = input().split()
  x1,x2,y1,y2 = int(x1),int(x2),int(y1),int(y2)
  dx,dy = x2-x1,y2-y1
  if dx!=0 and dy!=0 and abs(dx)!=abs(dy): 
    print('No')
    continue
  if dx<0 and dy<0:
    if (d1=='D' and d2=='R') or (d1=='L' and d2=='U'):
      print('Yes')
    else:
      print('No')
  elif dx<0 and dy>0:
    if (d1=='U' and d2=='R') or (d1=='L' and d2=='D'):
      print('Yes')
    else:
      print('No')
  elif dx>0 and dy<0:
    if (d1=='R' and d2=='U') or (d1=='D' and d2=='L'):
      print('Yes')
    else:
      print('No')
  elif dx>0 and dy>0:
    if (d1=='R' and d2=='D') or (d1=='U' and d2=='L'):
      print('Yes')
    else:
      print('No')
  elif dx==0 and dy==0: print('Yes')
  elif dx==0:
    if dy>0 and d1=='U' and d2=='D': print('Yes')
    elif dy<0 and d1=='D' and d2=='U': print('Yes')
    else: print('No')
  elif dy==0:
    if dx>0 and d1=='R' and d2=='L': print('Yes')
    elif dx<0 and d1=='L' and d2=='R': print('Yes')
    else: print('No')
0