結果

問題 No.2564 衝突予測
ユーザー n_na
提出日時 2024-01-05 00:00:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 429 ms / 2,000 ms
コード長 1,017 bytes
コンパイル時間 461 ms
コンパイル使用メモリ 82,416 KB
実行使用メモリ 77,560 KB
最終ジャッジ日時 2024-09-27 18:53:37
合計ジャッジ時間 6,541 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

for _ in range(T):
    x1,y1,d1 = map(str,input().split())
    x1,y1 = int(x1),int(y1)
    
    x2,y2,d2 = map(str,input().split())
    x2,y2 = int(x2),int(y2)
    
    col = False
    
    if x1 == x2:
        if y1 > y2 and d1 == "D" and d2 == "U":
            col = True
        if y1 < y2 and d1 == "U" and d2 == "D":
            col = True
        
    if y1 == y2:
        if x1 > x2 and d1 == "L" and d2 == "R":
            col = True
        if x1 < x2 and d1 == "R" and d2 == "L":
            col = True
            
    if abs(x2 - x1) == abs(y2 - y1):
        if x2 < x1:
            x1,x2,y1,y2,d1,d2 = x2,x1,y2,y1,d2,d1
        if y1 > y2 and d1 == "D" and d2 == "L":
            col = True
        if y1 > y2 and d1 == "R" and d2 == "U":
            col = True
        if y1 < y2 and d1 == "R" and d2 == "D":
            col = True
        if y1 < y2 and d1 == "U" and d2 == "L":
            col = True
    
    if col: print("Yes")
    else: print("No")
            
            
    
0