結果

問題 No.2564 衝突予測
ユーザー moharan627moharan627
提出日時 2023-12-02 16:28:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,450 bytes
コンパイル時間 589 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,492 KB
最終ジャッジ日時 2023-12-02 16:28:57
合計ジャッジ時間 4,669 ms
ジャッジサーバーID
(参考情報)
judge9 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,604 KB
testcase_01 AC 41 ms
55,604 KB
testcase_02 AC 35 ms
55,604 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10**9 + 7
MOD2 = 998244353
from collections import defaultdict
def ceil(A,B):
    return -(-A//B)
def line_cross_point(P0, P1, Q0, Q1):
    x0, y0 = P0; x1, y1 = P1
    x2, y2 = Q0; x3, y3 = Q1
    a0 = x1 - x0; b0 = y1 - y0
    a2 = x3 - x2; b2 = y3 - y2

    d = a0*b2 - a2*b0
    if d == 0:
        sn = b2 * (x2-x0) - a2 * (y2-y0)
        tn = b0 * (x2 - x0) - a0 * (y2 - y0)
        return sn,tn
    sn = b2 * (x2-x0) - a2 * (y2-y0)
    s = sn // d
    tn = b0 * (x2-x0) - a0 * (y2-y0)
    t = tn//d
    return s,t
def solve():
    def II(): return int(sys.stdin.readline())
    def LI(): return list(map(int, sys.stdin.readline().split()))
    def LC(): return list(sys.stdin.readline().rstrip())
    def IC(): return [int(c) for c in sys.stdin.readline().rstrip()]
    def MI(): return map(int, sys.stdin.readline().split())
    T = int(input())
    D = {"D":(0,-1),"U":(0,1),"L":(-1,0),"R":(1,0)}
    for test in range(T):
        X1,Y1,D1 = input().split()
        X1 = int(X1)
        Y1 = int(Y1)
        P0 = (X1,Y1)
        P1 = (X1+D[D1][0],Y1+D[D1][1])
        X2, Y2, D2 = input().split()
        X2 = int(X2)
        Y2 = int(Y2)
        Q0 = (X2,Y2)
        Q1 = (X2+D[D2][0],Y2+D[D2][1])
        #print(P0,P1,Q0,Q1)
        s,t = line_cross_point(P0, P1, Q0, Q1)
        if(s==t):
            print("Yes")
        else:
            print("No")
    return
solve()
0