結果

問題 No.199 星を描こう
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-04-29 00:34:34
言語 Python2
(2.7.18)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,141 bytes
コンパイル時間 434 ms
コンパイル使用メモリ 6,720 KB
実行使用メモリ 6,628 KB
最終ジャッジ日時 2023-08-28 18:37:21
合計ジャッジ時間 1,743 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
6,512 KB
testcase_01 AC 14 ms
6,440 KB
testcase_02 AC 14 ms
6,604 KB
testcase_03 AC 16 ms
6,440 KB
testcase_04 AC 15 ms
6,568 KB
testcase_05 AC 15 ms
6,484 KB
testcase_06 AC 15 ms
6,624 KB
testcase_07 AC 16 ms
6,440 KB
testcase_08 AC 15 ms
6,556 KB
testcase_09 AC 15 ms
6,516 KB
testcase_10 AC 15 ms
6,628 KB
testcase_11 AC 15 ms
6,544 KB
testcase_12 AC 15 ms
6,440 KB
testcase_13 AC 15 ms
6,488 KB
testcase_14 AC 13 ms
6,600 KB
testcase_15 AC 15 ms
6,432 KB
testcase_16 AC 14 ms
6,536 KB
testcase_17 AC 14 ms
6,524 KB
testcase_18 AC 15 ms
6,572 KB
testcase_19 AC 15 ms
6,436 KB
testcase_20 AC 13 ms
6,444 KB
testcase_21 AC 15 ms
6,444 KB
testcase_22 AC 12 ms
6,460 KB
testcase_23 AC 12 ms
6,444 KB
testcase_24 AC 15 ms
6,464 KB
testcase_25 AC 15 ms
6,484 KB
testcase_26 AC 12 ms
6,588 KB
testcase_27 AC 15 ms
6,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

xys = []
for _ in xrange(5):
    x, y = map(float, raw_input().split())
    xys.append(Point(x, y))

from itertools import permutations
from itertools import izip, tee, islice
def pairwise(iterable):
    "s -> (s0,s1), (s1,s2), (s2,s3), ..."
    a, b = tee(iterable)
    next(b, None)
    return izip(a, b)

for x in permutations(xys):
    x = list(x)
    y = x + [x[0]]
    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))
#    print sett
    if len(sett) == 5:
        print 'YES'
        exit(0)
print 'NO'
0