結果

問題 No.1041 直線大学
ユーザー nephrologistnephrologist
提出日時 2020-05-01 23:00:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 884 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 11,004 KB
実行使用メモリ 10,044 KB
最終ジャッジ日時 2023-08-26 15:40:16
合計ジャッジ時間 2,327 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,740 KB
testcase_01 AC 16 ms
8,604 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 18 ms
8,640 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 24 ms
8,784 KB
testcase_11 AC 25 ms
8,812 KB
testcase_12 AC 24 ms
8,744 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 17 ms
8,736 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 17 ms
8,824 KB
testcase_29 AC 17 ms
8,824 KB
testcase_30 AC 16 ms
8,740 KB
testcase_31 AC 17 ms
8,740 KB
testcase_32 AC 16 ms
8,640 KB
testcase_33 AC 16 ms
8,712 KB
testcase_34 AC 17 ms
8,668 KB
testcase_35 AC 16 ms
8,816 KB
testcase_36 AC 17 ms
8,652 KB
testcase_37 AC 17 ms
8,644 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 - 1):
        for j in range(i + 1, n):
            xi, yi = XY[i]
            xj, yj = XY[j]
            dx = xi - xj
            dy = yi - yj
            if dx < 0:
                dx *= -1
                dy *= -1
            g = gcd(dx, dy)
            dx //= g
            dy //= g
            dictionary1[(dx, dy)] += 1
            dictionary2[(dx, dy)].add(i)
            dictionary2[(dx, dy)].add(j)

    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