結果
| 問題 |
No.1041 直線大学
|
| コンテスト | |
| ユーザー |
nephrologist
|
| 提出日時 | 2020-05-01 22:18:47 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,610 bytes |
| コンパイル時間 | 365 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-12-25 12:28:42 |
| 合計ジャッジ時間 | 5,201 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 WA * 18 |
ソースコード
# import sys
# read = sys.stdin.buffer.read
# readline = sys.stdin.buffer.readline
# readlines = sys.stdin.buffer.readlines
n = int(input())
XY = []
for i in range(n):
x, y = map(int, input().split())
XY.append((x, y))
# 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 - 1):
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 == 0 and dx2 == 0:
unite(i, j)
unite(j, k)
elif dy1 == 0 and dy2 == 0:
unite(i, j)
unite(j, k)
elif dx1 == 0 or dx2 == 0 or dy1 == 0 or dy2 == 0:
continue
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