結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
55,600 KB
testcase_01 AC 40 ms
55,600 KB
testcase_02 AC 40 ms
55,600 KB
testcase_03 AC 394 ms
77,364 KB
testcase_04 AC 367 ms
77,364 KB
testcase_05 AC 382 ms
77,364 KB
testcase_06 AC 383 ms
77,364 KB
testcase_07 AC 398 ms
77,364 KB
testcase_08 AC 376 ms
77,364 KB
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 D
1 5 U

2
1 1 U
1 5 D
3 2 D
5 4 R

"""
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):
                E0 = abs(P0[0]-Q0[0])+abs(P0[1]-Q0[1])
                E1 = abs(P1[0]-Q1[0])+abs(P1[1]-Q1[1])
                #print(E0,E1)
                if(E1<E0):
                    print("Yes")
                else:
                    print("No")
            else:
                print("No")
        else:#並行でない
            s,t = C
            #print(s,t)
            if(s==t and s>0 and t > 0):
                print("Yes")
            else:
                print("No")
    return
solve()
0