結果
問題 | No.2564 衝突予測 |
ユーザー | u_kun |
提出日時 | 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 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
52,096 KB |
testcase_01 | AC | 45 ms
52,224 KB |
testcase_02 | AC | 42 ms
52,224 KB |
testcase_03 | AC | 606 ms
78,548 KB |
testcase_04 | AC | 599 ms
78,576 KB |
testcase_05 | AC | 602 ms
78,704 KB |
testcase_06 | AC | 605 ms
79,224 KB |
testcase_07 | AC | 599 ms
78,464 KB |
testcase_08 | AC | 595 ms
79,016 KB |
testcase_09 | AC | 630 ms
79,620 KB |
testcase_10 | AC | 637 ms
79,368 KB |
testcase_11 | AC | 634 ms
79,360 KB |
ソースコード
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")