結果
問題 | No.2564 衝突予測 |
ユーザー | yaakiyu |
提出日時 | 2023-12-02 15:51:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 274 ms / 2,000 ms |
コード長 | 1,846 bytes |
コンパイル時間 | 167 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 77,956 KB |
最終ジャッジ日時 | 2023-12-02 15:51:08 |
合計ジャッジ時間 | 3,915 ms |
ジャッジサーバーID (参考情報) |
judge9 / judge10 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
53,460 KB |
testcase_01 | AC | 38 ms
53,460 KB |
testcase_02 | AC | 38 ms
53,460 KB |
testcase_03 | AC | 239 ms
77,584 KB |
testcase_04 | AC | 244 ms
77,580 KB |
testcase_05 | AC | 241 ms
77,320 KB |
testcase_06 | AC | 250 ms
77,564 KB |
testcase_07 | AC | 242 ms
77,824 KB |
testcase_08 | AC | 240 ms
77,572 KB |
testcase_09 | AC | 267 ms
77,956 KB |
testcase_10 | AC | 259 ms
77,828 KB |
testcase_11 | AC | 274 ms
77,956 KB |
ソースコード
import sys input = lambda: sys.stdin.readline()[:-1] sys.setrecursionlimit(1000000) t = int(input()) for i in range(t): x,y,d = input().split() x,y = int(x), int(y) x2,y2,d2 = input().split() x2,y2 = int(x2), int(y2) if d in "RL" and d2 in "RL": # 横方向での衝突を考える if y != y2: print("No") elif x < x2: # a -> <- b の場合のみ衝突 if d == "R" and d2 == "L": print("Yes") else: print("No") else: # b -> <- a の場合のみ衝突 if d == "L" and d2 == "R": print("Yes") else: print("No") continue if d in "UD" and d2 in "UD": # 縦方向での衝突を考える if x != x2: print("No") elif y < y2: # ^ v の場合のみ衝突 if d == "U" and d2 == "D": print("Yes") else: print("No") else: # v ^ の場合のみ衝突 if d == "D" and d2 == "U": print("Yes") else: print("No") continue if d2 in "UD": # d1がUD、d2がRLになるように入れ替える x, y, d, x2, y2, d2 = x2, y2, d2, x, y, d # 衝突予想地点 sx, sy = x, y2 # ここを通るかどうかを確認する if not ((d == "U" and y < sy) or (d == "D" and y > sy)): # aが通らない print("No") continue if not ((d2 == "R" and x2 < sx) or (d2 == "L" and x2 > sx)): # bが通らない print("No") continue # 到着予想時刻の計算 yosou_a = abs(sy-y) yosou_b = abs(sx-x2) if yosou_a == yosou_b: print("Yes") else: print("No")