結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
55,600 KB
testcase_01 AC 37 ms
55,600 KB
testcase_02 AC 43 ms
55,600 KB
testcase_03 AC 371 ms
77,364 KB
testcase_04 AC 405 ms
77,364 KB
testcase_05 AC 383 ms
77,364 KB
testcase_06 AC 380 ms
77,364 KB
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:

        return None
    sn = b2 * (x2-x0) - a2 * (y2-y0)
    s = sn // d
    tn = b0 * (x2-x0) - a0 * (y2-y0)
    t = tn//d
    return s,t
"""
2
1 1 U
1 5 D
1 1 U
1 5 U
"""
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)
        C = line_cross_point(P0, P1, Q0, Q1)
        if (D1 == D2):
            print("No")
        elif(C==None):#並行
            if(X1==X2 or Y1==Y2):
                D0 = abs(X1-X2)+abs(Y1-Y2)
                D1 = abs(P1[0]-Q1[0])+abs(P1[1]-Q1[1])
                if(D1<D0):
                    print("Yes")
                else:
                    print("No")
            else:
                print("No")
        else:
            s,t = C
            if(s==t):
                print("Yes")
            else:
                print("No")
    return
solve()
0