結果
| 問題 |
No.635 自然門松列
|
| コンテスト | |
| ユーザー |
fiord
|
| 提出日時 | 2018-03-10 03:26:05 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 965 bytes |
| コンパイル時間 | 670 ms |
| コンパイル使用メモリ | 82,044 KB |
| 実行使用メモリ | 61,268 KB |
| 最終ジャッジ日時 | 2024-10-11 06:06:32 |
| 合計ジャッジ時間 | 2,345 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 19 WA * 4 |
ソースコード
def solve(a,b,c,d,e,f):
# 元のやつは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")
fiord