結果

問題 No.2769 Number of Rhombi
ユーザー tassei903tassei903
提出日時 2024-06-01 00:48:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,400 ms / 5,000 ms
コード長 1,178 bytes
コンパイル時間 373 ms
コンパイル使用メモリ 82,364 KB
実行使用メモリ 367,592 KB
最終ジャッジ日時 2024-06-01 00:49:48
合計ジャッジ時間 42,745 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
54,860 KB
testcase_01 AC 44 ms
55,436 KB
testcase_02 AC 48 ms
60,524 KB
testcase_03 AC 1,196 ms
282,044 KB
testcase_04 AC 1,118 ms
280,996 KB
testcase_05 AC 829 ms
210,320 KB
testcase_06 AC 1,030 ms
250,632 KB
testcase_07 AC 1,303 ms
282,196 KB
testcase_08 AC 1,293 ms
277,512 KB
testcase_09 AC 1,344 ms
278,584 KB
testcase_10 AC 1,360 ms
291,204 KB
testcase_11 AC 1,320 ms
320,164 KB
testcase_12 AC 1,324 ms
331,708 KB
testcase_13 AC 1,393 ms
366,988 KB
testcase_14 AC 1,366 ms
367,248 KB
testcase_15 AC 1,372 ms
367,212 KB
testcase_16 AC 1,397 ms
367,224 KB
testcase_17 AC 1,330 ms
367,476 KB
testcase_18 AC 1,382 ms
367,352 KB
testcase_19 AC 1,357 ms
367,324 KB
testcase_20 AC 1,337 ms
367,328 KB
testcase_21 AC 1,387 ms
354,776 KB
testcase_22 AC 1,395 ms
354,676 KB
testcase_23 AC 1,293 ms
350,100 KB
testcase_24 AC 44 ms
54,900 KB
testcase_25 AC 1,400 ms
367,004 KB
testcase_26 AC 1,369 ms
367,220 KB
testcase_27 AC 1,378 ms
367,280 KB
testcase_28 AC 1,341 ms
367,336 KB
testcase_29 AC 1,360 ms
367,592 KB
testcase_30 AC 1,391 ms
367,264 KB
testcase_31 AC 1,361 ms
331,820 KB
testcase_32 AC 1,285 ms
277,144 KB
testcase_33 AC 1,324 ms
277,780 KB
testcase_34 AC 1,333 ms
286,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################

from math import gcd
def f(x1, y1, x2, y2):
    a = y2 - y1
    b = - (x2 - x1)
    c = -x1 * y2 + x2 * y1
    g = gcd(a, gcd(b, c))
    a //= g
    b //= g
    c //= g
    if (a, b, c) < (-a, -b, -c):
        a, b, c = -a, -b, -c
    return a, b, c

n = ni()
p = [na() for _ in range(n)]

from collections import defaultdict

d = defaultdict(int)
c = defaultdict(int)
for i in range(n):
    for j in range(i+1, n):
        x1, y1 = p[i]
        x2, y2 = p[j]
        dx, dy = x2 - x1, y2 - y1
        if (dx, dy) < (-dx, -dy):
            dx, dy = -dx, -dy
        g = gcd(dx, dy)
        d[(x1+x2, y1+y2, dx // g, dy // g)] += 1
ans = 0
#print(d)
for x, y, dx, dy in list(d.keys()):
    DX, DY = dy, -dx
    if (DX, DY) < (-DX, -DY):
        DX, DY = -DX, -DY
    ans += d[(x, y, DX, DY)] * d[(x, y, dx, dy)]
print(ans//2)
0