結果
| 問題 | No.199 星を描こう |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-04-29 00:37:25 |
| 言語 | PyPy2 (7.3.20) |
| 結果 |
AC
|
| 実行時間 | 260 ms / 2,000 ms |
| コード長 | 1,002 bytes |
| 記録 | |
| コンパイル時間 | 145 ms |
| コンパイル使用メモリ | 77,612 KB |
| 最終ジャッジ日時 | 2025-12-03 14:52:47 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#!/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'