結果

問題 No.1041 直線大学
ユーザー nephrologistnephrologist
提出日時 2020-05-01 22:18:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,610 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 11,148 KB
実行使用メモリ 8,292 KB
最終ジャッジ日時 2023-08-26 14:44:33
合計ジャッジ時間 3,831 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,104 KB
testcase_01 AC 14 ms
8,092 KB
testcase_02 AC 15 ms
8,088 KB
testcase_03 AC 14 ms
8,180 KB
testcase_04 AC 15 ms
8,164 KB
testcase_05 AC 14 ms
8,116 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 411 ms
8,120 KB
testcase_11 AC 415 ms
8,108 KB
testcase_12 AC 303 ms
8,052 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 15 ms
8,136 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 15 ms
8,160 KB
testcase_21 WA -
testcase_22 AC 14 ms
8,056 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 13 ms
8,080 KB
testcase_29 AC 14 ms
8,188 KB
testcase_30 AC 13 ms
8,100 KB
testcase_31 AC 13 ms
8,120 KB
testcase_32 AC 14 ms
8,212 KB
testcase_33 AC 14 ms
8,216 KB
testcase_34 AC 14 ms
8,240 KB
testcase_35 AC 15 ms
8,032 KB
testcase_36 AC 14 ms
8,108 KB
testcase_37 AC 13 ms
8,084 KB
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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