結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,320 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 13 ms
8,192 KB
testcase_29 AC 14 ms
8,248 KB
testcase_30 AC 14 ms
8,368 KB
testcase_31 AC 14 ms
8,268 KB
testcase_32 AC 14 ms
8,160 KB
testcase_33 AC 14 ms
8,328 KB
testcase_34 AC 13 ms
8,300 KB
testcase_35 AC 14 ms
8,232 KB
testcase_36 AC 13 ms
8,232 KB
testcase_37 AC 13 ms
8,372 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))

par = [-1] * (n + 1)

# union-find
# xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


# xとyの属する集合の併合
def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    else:
        # sizeの大きい方をxとする
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True


# xとyが同じ集合か判定
def same(x, y):
    return find(x) == find(y)


def size(x):
    return -par[find(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