結果

問題 No.635 自然門松列
ユーザー fiordfiord
提出日時 2018-03-10 03:31:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 86 ms / 650 ms
コード長 1,039 bytes
コンパイル時間 734 ms
コンパイル使用メモリ 87,352 KB
実行使用メモリ 76,356 KB
最終ジャッジ日時 2023-09-05 13:12:39
合計ジャッジ時間 3,218 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,832 KB
testcase_01 AC 70 ms
71,504 KB
testcase_02 AC 72 ms
71,452 KB
testcase_03 AC 71 ms
71,320 KB
testcase_04 AC 74 ms
71,692 KB
testcase_05 AC 86 ms
76,256 KB
testcase_06 AC 86 ms
76,356 KB
testcase_07 AC 86 ms
76,152 KB
testcase_08 AC 72 ms
71,816 KB
testcase_09 AC 72 ms
71,732 KB
testcase_10 AC 77 ms
76,292 KB
testcase_11 AC 77 ms
76,284 KB
testcase_12 AC 78 ms
76,140 KB
testcase_13 AC 77 ms
76,156 KB
testcase_14 AC 76 ms
76,252 KB
testcase_15 AC 70 ms
71,940 KB
testcase_16 AC 70 ms
71,532 KB
testcase_17 AC 78 ms
76,288 KB
testcase_18 AC 78 ms
76,276 KB
testcase_19 AC 79 ms
76,192 KB
testcase_20 AC 79 ms
76,232 KB
testcase_21 AC 77 ms
76,116 KB
testcase_22 AC 78 ms
76,168 KB
testcase_23 AC 78 ms
76,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(a,b,c,d,e,f):
    if [a,b]==[c,d] or [c,d]==[e,f] or [e,f]==[a,b]:
        return False
    # 元のやつはax+b,cx+d,ex+fで成長。差を取って、
    # s:(a-c)x+(b-d)
    # t:(e-c)x+(f-d)
    sa=a-c
    sb=b-d
    ta=e-c
    tb=f-d
    # sとtが同符号、つまりs*t>0となるxがx>=0に存在すればOK。
    # (sa*x+sb)*(ta*x+tb)=Ax^2+Bx+C>0だよね。
    A=sa*ta
    B=sa*tb+sb*ta
    C=sb*tb
    if A>0:
        # x=inf でs*t>0。だからOK。
        return True
    elif A==0:
        # s*t=Bx+C。B>0もしくはC>0でOK。
        return C>0 or B>0
    else:
        # Ax^2+Bx+C=0が2つの異なる実数解を持っている必要がある。
        if B*B<=4*A*C:
            return False
        # [p,q]の間でs*t>0→p>0かq>0でOK。
        return (-B+(B*B-4*A*C)**0.5)/(2*A)>0 or (-B-(B*B-4*A*C)**0.5)/(2*A)>0

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