結果

問題 No.635 自然門松列
ユーザー fiordfiord
提出日時 2018-03-10 02:05:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 921 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 83,200 KB
最終ジャッジ日時 2024-04-19 13:41:15
合計ジャッジ時間 4,908 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
80,168 KB
testcase_01 AC 101 ms
80,184 KB
testcase_02 AC 110 ms
81,536 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 117 ms
81,244 KB
testcase_09 AC 113 ms
81,536 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from decimal import *

def solve(a,b,c,d,e,f):
    sa=a-c
    sb=b-d
    ta=e-c
    tb=f-d
    # if there are any x>0 which makes s*t>0, it is answer.
    # (sa*x+sb)*(ta*x+tb)=Ax^2+Bx+C>0
    A=sa*ta
    B=sa*tb+sb*ta
    C=sb*tb
    if A<Decimal(0):
        A*=-1
        B*=-1
        C*=-1
    if A>Decimal(0):
        # x=inf then f>0.OK
        return True
    elif A==Decimal(0):
        # f=Bx+C,C>0 or B>0 then OK.
        return C>Decimal(0) or B>Decimal(0)
    else:
        if B*B<4*A*C:
            return False
        # we can find two answers(suppose it's p and q).
        # if [p,q] contains positive number, is's OK.
        # => q=(-B+sqrt(B**2 - 4AC))/(2A)>0
        return (-B+(B*B-4*A*C).sqrt())/(2*A)>Decimal(0)

n=int(input())
for i in range(n):
    dat=list(map(Decimal,input().split()))
    if solve(dat[3],dat[0],dat[4],dat[1],dat[5],dat[2]):
        print("YES")
    else:
        print("NO")
0