結果

問題 No.635 自然門松列
ユーザー wajima_wataruwajima_wataru
提出日時 2018-03-03 12:57:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 19 ms / 650 ms
コード長 876 bytes
コンパイル時間 598 ms
コンパイル使用メモリ 10,776 KB
実行使用メモリ 7,932 KB
最終ジャッジ日時 2023-09-05 13:12:07
合計ジャッジ時間 1,699 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,932 KB
testcase_01 AC 16 ms
7,880 KB
testcase_02 AC 16 ms
7,796 KB
testcase_03 AC 17 ms
7,776 KB
testcase_04 AC 16 ms
7,832 KB
testcase_05 AC 19 ms
7,872 KB
testcase_06 AC 18 ms
7,748 KB
testcase_07 AC 18 ms
7,932 KB
testcase_08 AC 16 ms
7,820 KB
testcase_09 AC 16 ms
7,932 KB
testcase_10 AC 18 ms
7,828 KB
testcase_11 AC 17 ms
7,800 KB
testcase_12 AC 18 ms
7,776 KB
testcase_13 AC 18 ms
7,776 KB
testcase_14 AC 18 ms
7,816 KB
testcase_15 AC 15 ms
7,876 KB
testcase_16 AC 15 ms
7,920 KB
testcase_17 AC 18 ms
7,820 KB
testcase_18 AC 18 ms
7,872 KB
testcase_19 AC 18 ms
7,832 KB
testcase_20 AC 18 ms
7,892 KB
testcase_21 AC 18 ms
7,816 KB
testcase_22 AC 18 ms
7,796 KB
testcase_23 AC 18 ms
7,820 KB
権限があれば一括ダウンロードができます

ソースコード

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