結果
問題 | No.2564 衝突予測 |
ユーザー |
|
提出日時 | 2023-12-02 16:54:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 637 ms / 2,000 ms |
コード長 | 2,351 bytes |
コンパイル時間 | 324 ms |
コンパイル使用メモリ | 81,736 KB |
実行使用メモリ | 79,620 KB |
最終ジャッジ日時 | 2024-09-26 20:51:21 |
合計ジャッジ時間 | 7,117 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 |
ソースコード
def manh_check(x1, y1, x2, y2): if abs(x1 - x2) == abs(y1 - y2): return True else: return False def direction(x1, y1, x2, y2): # (x1, y1)は(x2, y2)よりもなんなのか? if x1 < x2 and y1 > y2: return "hidariue" elif x1 < x2 and y1 < y2: return "hidarisita" elif x1 > x2 and y1> y2: return "migiue" elif x1 > x2 and y1 < y2: return "migisita" else: return "None" T = int(input()) for _ in range(T): x1, y1, D1 = input().split() x2, y2, D2 = input().split() x1 = int(x1) x2 = int(x2) y1 = int(y1) y2 = int(y2) if D1 == D2: print("No") continue Flg = False if D1 == "U" and D2 == "R": if direction(x2, y2, x1, y1) == "hidariue" and manh_check(x1, y1, x2, y2): Flg = True elif D1 == "R" and D2 == "U": if direction(x2, y2, x1, y1) == "migisita" and manh_check(x1, y1, x2, y2): Flg = True elif D1 == "U" and D2 == "L": if direction(x2, y2, x1, y1) == "migiue" and manh_check(x1, y1, x2, y2): Flg = True elif D1 == "L" and D2 == "U": if direction(x2, y2, x1, y1) == "hidarisita" and manh_check(x1, y1, x2, y2): Flg = True elif D1 == "U" and D2 == "D": if x1 == x2 and y2 > y1: Flg = True elif D1 == "D" and D2 == "U": if x1 == x2 and y2 < y1: Flg = True elif D1 == "D" and D2 == "R": if direction(x2, y2, x1, y1) == "hidarisita" and manh_check(x1, y1, x2, y2): Flg = True elif D1 == "R" and D2 == "D": if direction(x2, y2, x1, y1) == "migiue" and manh_check(x1, y1, x2, y2): Flg = True elif D1 == "D" and D2 == "L": if direction(x2, y2, x1, y1) == "migisita" and manh_check(x1, y1, x2, y2): Flg = True elif D1 == "L" and D2 == "D": if direction(x2, y2, x1, y1) == "hidariue" and manh_check(x1, y1, x2, y2): Flg = True elif D1 == "R" and D2 == "L": if y1 == y2 and x1 < x2: Flg = True elif D1 == "L" and D2 == "R": if y1 == y2 and x1 > x2: Flg = True if Flg: print("Yes") else: print("No")