結果

問題 No.635 自然門松列
ユーザー nebukuro09
提出日時 2018-05-19 04:53:18
言語 Python2
(2.7.18)
結果
AC  
実行時間 62 ms / 650 ms
コード長 878 bytes
コンパイル時間 43 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 8,064 KB
最終ジャッジ日時 2024-06-28 14:18:24
合計ジャッジ時間 1,679 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

from fractions import Fraction


def is_kadomatsu(a, b, c):
    return b < a < c or b < c < a or b > a > c or b > c > a


def solve():
    x1, x2, x3, y1, y2, y3 = map(int, raw_input().split())

    if is_kadomatsu(x1, x2, x3):
        return "YES"

    T = []

    if y1 != y2:
        T.append(Fraction(x1-x2, y2-y1))
    if y2 != y3:
        T.append(Fraction(x2-x3, y3-y2))
    if y3 != y1:
        T.append(Fraction(x3-x1, y1-y3))

    d = Fraction(1, 10**18)

    for t in T:
        if t < 0:
            continue
        for sign in (1, -1):
            if t == 0 and sign == -1:
                continue
            a1 = x1 + y1 * (t + sign * d)
            a2 = x2 + y2 * (t + sign * d)
            a3 = x3 + y3 * (t + sign * d)
            if is_kadomatsu(a1, a2, a3):
                return "YES"

    return "NO"


Q = input()
for _ in xrange(Q):
    print solve()
0