結果
| 問題 |
No.1041 直線大学
|
| コンテスト | |
| ユーザー |
nephrologist
|
| 提出日時 | 2020-05-01 21:37:12 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,255 bytes |
| コンパイル時間 | 163 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-12-24 23:27:20 |
| 合計ジャッジ時間 | 2,281 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 RE * 2 |
| other | AC * 10 RE * 27 |
ソースコード
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(input())
xy = map(int, read().split())
XY = list(zip(xy, xy))
# union-Find##
par = [-1] * (n + 1)
def root(x):
if par[x] < 0:
return x
else:
par[x] = root(par[x])
return par[x]
def unite(x, y):
a = root(x)
b = root(y)
if a == b:
return False
else:
if par[a] > par[b]:
a, b = b, a
par[a] += par[b]
par[b] = a
return True
def is_same(x, y):
return root(x) == root(y)
def size(x):
return -par[root(x)]
# 初期化
# 根なら-size、子なら親の頂点
if n >= 3:
for i in range(n - 2):
for j in range(i + 1, n):
for k in range(j + 1, n):
xi, yi = XY[i]
xj, yj = XY[j]
xk, yk = XY[k]
dx1 = xi - xj
dy1 = yi - yj
dx2 = xj - xk
dy2 = yj - yk
if dx1 * dy2 == dx2 * dy1:
unite(i, j)
unite(j, k)
ans = 2
for i in range(n):
ans = max(ans, size(i))
print(ans)
elif n == 2:
print(2)
else:
print(1)
nephrologist