結果
| 問題 |
No.245 貫け!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-07-17 23:30:58 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 108 ms / 5,000 ms |
| コード長 | 979 bytes |
| コンパイル時間 | 234 ms |
| コンパイル使用メモリ | 82,004 KB |
| 実行使用メモリ | 75,620 KB |
| 最終ジャッジ日時 | 2024-07-08 09:36:56 |
| 合計ジャッジ時間 | 2,273 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
def read_data():
N = int(input())
lines = []
points = set()
for i in range(N):
a, b, c, d = map(int, input().split())
lines.append((a, b, c, d))
points.add((a, b))
points.add((c, d))
return N, lines, points
def solve(N, lines, points):
points = list(points)
record = 0
for i, (x1, y1) in enumerate(points[:-1]):
for j, (x2 ,y2) in enumerate(points[i+1:], i+1):
n_cross = count_cross(x1, y1, x2, y2, lines)
if n_cross > record:
record = n_cross
return record
def count_cross(x1, y1, x2, y2, lines):
n_cross = 0
dx = x2 - x1
dy = y2 - y1
for a, b, c, d in lines:
if opposite_side(x1, y1, dx, dy, a, b, c, d):
n_cross += 1
return n_cross
def opposite_side(x1, y1, dx, dy, a, b, c, d):
return (dx*(b - y1) - dy*(a - x1)) * (dx*(d - y1) - dy*(c - x1)) <= 0
N, lines, points = read_data()
print(solve(N, lines, points))