結果

問題 No.635 自然門松列
ユーザー wajima_wataru
提出日時 2018-03-03 12:57:11
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 650 ms
コード長 876 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-06-23 08:51:28
合計ジャッジ時間 1,493 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

def get_ans(x, x1, x2, x3, y1, y2, y3):
    p1 = x1 + y1 * x
    p2 = x2 + y2 * x
    p3 = x3 + y3 * x
    if (p1 < p2 and p3 < p2 and p1 != p3) or (p1 > p2 and p3 > p2 and p1 != p3):
        return True
    return False

N = int(input())

for _ in range(N):
    x1, x2, x3, y1, y2, y3 = map(int, input().split())
    ps = [(x1 - x2) / (y2 - y1) if y1 != y2 else -1,
          (x2 - x3) / (y3 - y2) if y2 != y3 else -1,
          (x1 - x3) / (y3 - y1) if y1 != y3 else -1]
    if 0 not in ps:
        ps.append(0)
    ps.sort()
    ps.append(ps[-1] + 1.0)
    ans = False
    for i in range(len(ps) - 1):
        if ps[i] < 0:
            continue
        if get_ans(ps[i] + ((ps[i + 1] - ps[i]) / 3), x1, x2, x3, y1, y2, y3) or get_ans(ps[i] + ((ps[i + 1] - ps[i]) * 2 / 3), x1, x2, x3, y1, y2, y3):
            ans = True
            break
    print('YES' if ans else 'NO')
0