結果
| 問題 | No.2564 衝突予測 | 
| コンテスト | |
| ユーザー |  nzm_ort | 
| 提出日時 | 2023-12-02 16:55:48 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 505 ms / 2,000 ms | 
| コード長 | 1,868 bytes | 
| コンパイル時間 | 206 ms | 
| コンパイル使用メモリ | 81,920 KB | 
| 実行使用メモリ | 79,120 KB | 
| 最終ジャッジ日時 | 2024-09-26 20:53:32 | 
| 合計ジャッジ時間 | 6,097 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 9 | 
ソースコード
t = int(input())
for _ in range(t):
    x1, y1, d1 = map(str, input().split())
    x2, y2, d2 = map(str, input().split())
    x1, y1 = int(x1), int(y1)
    x2, y2 = int(x2), int(y2)
    
    if (d1=="U" or d1=="D") and (d2=="U" or d2=="D"):
        if x1!=x2: print('No'); continue
    if (d1=="L" or d1=="R") and (d2=="L" or d2=="R"):
        if y1!=y2: print('No'); continue
    
    if x1==x2:
        if (d1=="U" and d2=="D"):
            if y1<y2: print('Yes'); continue
            else: print('No'); continue
        elif (d1=="D" and d2=="U"):
            if y1>y2: print('Yes'); continue
            else: print('No'); continue
        else: print('No'); continue
    elif y1==y2:
        if (d1=="L" and d2=="R"):
            if x1>x2: print('Yes'); continue
            else: print('No'); continue
        elif (d1=="R" and d2=="L"):
            if x1<x2: print('Yes'); continue
            else: print('No'); continue
        else: print('No'); continue
    else:
        f = True
        if d1=="U":
            if y1>y2: print('No'); f=False
            else: t1=y2-y1
        elif d1=="D":
            if y1<y2: print('No'); f=False
            else: t1=y1-y2
        elif d1=="L":
            if x1<x2: print('No'); f=False
            else: t1=x1-x2
        else:
            if x1>x2: print('No'); f=False
            else: t1=x2-x1
        
        if f:
            if d2=="U":
                if y1<y2: print('No'); f=False
                else: t2=y1-y2
            elif d2=="D":
                if y1>y2: print('No'); f=False
                else: t2=y2-y1
            elif d2=="L":
                if x1>x2: print('No'); f=False
                else: t2=x2-x1
            else:
                if x1<x2: print('No'); f=False
                else: t2=x1-x2
        
        if f:
            if t1==t2: print('Yes')
            else: print('No')
            
            
            
        