結果

問題 No.199 星を描こう
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-04-29 00:37:25
言語 Python2
(2.7.18)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 1,002 bytes
コンパイル時間 644 ms
コンパイル使用メモリ 6,712 KB
実行使用メモリ 7,904 KB
最終ジャッジ日時 2023-08-28 18:37:27
合計ジャッジ時間 3,276 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
7,664 KB
testcase_01 AC 74 ms
7,840 KB
testcase_02 AC 73 ms
7,684 KB
testcase_03 AC 88 ms
7,868 KB
testcase_04 AC 87 ms
7,844 KB
testcase_05 AC 88 ms
7,864 KB
testcase_06 AC 89 ms
7,688 KB
testcase_07 AC 86 ms
7,868 KB
testcase_08 AC 87 ms
7,700 KB
testcase_09 AC 88 ms
7,856 KB
testcase_10 AC 86 ms
7,692 KB
testcase_11 AC 87 ms
7,636 KB
testcase_12 AC 87 ms
7,684 KB
testcase_13 AC 87 ms
7,684 KB
testcase_14 AC 27 ms
7,700 KB
testcase_15 AC 81 ms
7,764 KB
testcase_16 AC 45 ms
7,620 KB
testcase_17 AC 68 ms
7,804 KB
testcase_18 AC 82 ms
7,676 KB
testcase_19 AC 73 ms
7,760 KB
testcase_20 AC 29 ms
7,752 KB
testcase_21 AC 88 ms
7,804 KB
testcase_22 AC 23 ms
7,860 KB
testcase_23 AC 24 ms
7,904 KB
testcase_24 AC 89 ms
7,672 KB
testcase_25 AC 85 ms
7,712 KB
testcase_26 AC 27 ms
7,660 KB
testcase_27 AC 81 ms
7,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python
# -*- coding: utf-8 -*-
# †
# (ΦωΦ)<
# 交点が5つあるかどうかでいいですか?
from collections import namedtuple
Point = namedtuple('Point', 'x, y')

from fractions import Fraction
xys = []
for _ in xrange(5):
    x, y = map(lambda e: Fraction(e).limit_denominator(), raw_input().split())
    xys.append(Point(x, y))

from itertools import permutations

for x in permutations(xys):
    x = list(x)
    sett = set()
    for i in xrange(5):
        a, b, c, d = (i+1)%5, (i+2)%5, (i+3)%5, (i+4)%5
        a, b, c, d = x[a], x[b], x[c], x[d]
        bunbo = (b.x - a.x) * (d.y - c.y) - (b.y - a.y) * (d.x - c.x)
        if bunbo == 0:
            continue
        ac = Point(c.x - a.x, c.y - a.y)
        dr = ((d.y - c.y) * ac.x - (d.x - c.x) * ac.y) / bunbo
        if 0 < dr < 1:
            px = a.x + dr * (b.x - a.x)
            py = a.y + dr * (b.y - a.y)
            sett.add(Point(px, py))
    if len(sett) == 5:
        print 'YES'
        exit(0)
print 'NO'
0