結果

問題 No.1041 直線大学
ユーザー nephrologistnephrologist
提出日時 2020-05-01 23:05:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,349 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 11,108 KB
実行使用メモリ 8,936 KB
最終ジャッジ日時 2023-08-26 15:42:51
合計ジャッジ時間 4,455 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,876 KB
testcase_01 AC 18 ms
8,708 KB
testcase_02 RE -
testcase_03 WA -
testcase_04 WA -
testcase_05 RE -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 404 ms
8,812 KB
testcase_11 AC 358 ms
8,660 KB
testcase_12 AC 414 ms
8,844 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 39 ms
8,720 KB
testcase_16 WA -
testcase_17 AC 18 ms
8,880 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 RE -
testcase_21 WA -
testcase_22 RE -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 15 ms
8,844 KB
testcase_29 AC 16 ms
8,652 KB
testcase_30 AC 17 ms
8,720 KB
testcase_31 AC 17 ms
8,688 KB
testcase_32 AC 17 ms
8,788 KB
testcase_33 AC 16 ms
8,724 KB
testcase_34 AC 17 ms
8,676 KB
testcase_35 AC 17 ms
8,692 KB
testcase_36 AC 15 ms
8,680 KB
testcase_37 AC 15 ms
8,680 KB
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
from collections import defaultdict, Counter

n = int(input())
XY = []
for i in range(n):
    x, y = map(int, input().split())
    XY.append((x, y))

dictionary1 = defaultdict(int)
dictionary2 = defaultdict(set)
ans = set()
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]
                dx = xi - xj
                dy = yi - yj
                ddx = xj - xk
                ddy = yj - yk

                if dx < 0:
                    dx *= -1
                    dy *= -1
                if ddx < 0:
                    ddx *= -1
                    ddy *= -1
                g = gcd(dx, dy)
                dx //= g
                dy //= g
                gg = gcd(ddx, ddy)
                ddx //= gg
                ddy //= gg
                if dx * ddy == ddx * dy:
                    dictionary1[(dx, dy)] += 1
                    dictionary2[(dx, dy)].add(i)
                    dictionary2[(dx, dy)].add(j)
                    dictionary2[(dx, dy)].add(k)

    DC = Counter(dictionary1)
    katamuki = DC.most_common()[0][0]
    for num in dictionary2[katamuki]:
        ans.add(num)
    print(len(list(ans)))
elif n == 2:
    print(2)
else:
    print(1)
0