結果

問題 No.1041 直線大学
ユーザー nephrologistnephrologist
提出日時 2020-05-01 21:37:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,255 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 11,000 KB
実行使用メモリ 8,380 KB
最終ジャッジ日時 2023-08-26 07:31:08
合計ジャッジ時間 2,353 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,352 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 14 ms
8,212 KB
testcase_29 AC 14 ms
8,268 KB
testcase_30 AC 14 ms
8,364 KB
testcase_31 AC 15 ms
8,300 KB
testcase_32 AC 15 ms
8,208 KB
testcase_33 AC 14 ms
8,236 KB
testcase_34 AC 15 ms
8,340 KB
testcase_35 AC 14 ms
8,304 KB
testcase_36 AC 15 ms
8,304 KB
testcase_37 AC 15 ms
8,264 KB
testcase_38 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0