結果

問題 No.2769 Number of Rhombi
ユーザー mkawa2mkawa2
提出日時 2024-05-31 22:33:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,000 ms / 5,000 ms
コード長 1,496 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 82,992 KB
実行使用メモリ 226,148 KB
最終ジャッジ日時 2024-05-31 22:34:24
合計ジャッジ時間 29,001 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,240 KB
testcase_01 AC 45 ms
55,136 KB
testcase_02 AC 48 ms
59,644 KB
testcase_03 AC 893 ms
198,712 KB
testcase_04 AC 819 ms
178,476 KB
testcase_05 AC 669 ms
142,756 KB
testcase_06 AC 789 ms
162,184 KB
testcase_07 AC 981 ms
195,836 KB
testcase_08 AC 1,000 ms
197,652 KB
testcase_09 AC 963 ms
201,180 KB
testcase_10 AC 964 ms
209,920 KB
testcase_11 AC 906 ms
212,748 KB
testcase_12 AC 930 ms
220,276 KB
testcase_13 AC 863 ms
222,504 KB
testcase_14 AC 836 ms
223,476 KB
testcase_15 AC 883 ms
224,092 KB
testcase_16 AC 883 ms
224,564 KB
testcase_17 AC 829 ms
225,228 KB
testcase_18 AC 901 ms
225,900 KB
testcase_19 AC 831 ms
225,708 KB
testcase_20 AC 852 ms
225,680 KB
testcase_21 AC 857 ms
225,792 KB
testcase_22 AC 843 ms
226,148 KB
testcase_23 AC 860 ms
225,380 KB
testcase_24 AC 44 ms
55,000 KB
testcase_25 AC 858 ms
222,504 KB
testcase_26 AC 864 ms
222,996 KB
testcase_27 AC 808 ms
225,044 KB
testcase_28 AC 828 ms
224,132 KB
testcase_29 AC 876 ms
224,616 KB
testcase_30 AC 816 ms
224,508 KB
testcase_31 AC 912 ms
220,156 KB
testcase_32 AC 971 ms
197,452 KB
testcase_33 AC 953 ms
197,360 KB
testcase_34 AC 933 ms
207,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(1000006)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 62)

# md = 10**9+7
md = 998244353

from collections import Counter
from math import gcd

n = II()
xy = LLI(n)
cnt = Counter()

for i in range(n):
    x, y = xy[i]
    for j in range(i):
        s, t = xy[j]
        if x == s:
            cnt[inf, inf, x+s, y+t] += 1
        elif y == t:
            cnt[0, 0, x+s, y+t] += 1
        else:
            a = y-t
            b = x-s
            if a < 0: a, b = -a, -b
            g = gcd(a, b)
            a //= g
            b //= g
            cnt[a, b, x+s, y+t] += 1
ans = 0
for a, b, x, y in cnt:
    c=cnt[a,b,x,y]
    if a == 0:
        ans += cnt[inf, inf, x, y]*c
    elif a == inf:
        ans += cnt[0, 0, x, y]*c
    else:
        if b < 0: a, b = -a, -b
        ans += cnt[b, -a, x, y]*c

print(ans//2)
0