結果

問題 No.2769 Number of Rhombi
ユーザー ああいいああいい
提出日時 2024-06-01 17:09:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,143 ms / 5,000 ms
コード長 1,056 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 82,556 KB
実行使用メモリ 347,956 KB
最終ジャッジ日時 2024-06-01 17:10:37
合計ジャッジ時間 55,311 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,012 KB
testcase_01 AC 44 ms
54,296 KB
testcase_02 AC 42 ms
54,996 KB
testcase_03 AC 1,315 ms
252,956 KB
testcase_04 AC 1,257 ms
251,136 KB
testcase_05 AC 1,238 ms
201,284 KB
testcase_06 AC 1,489 ms
240,476 KB
testcase_07 AC 1,771 ms
276,760 KB
testcase_08 AC 1,811 ms
306,844 KB
testcase_09 AC 1,753 ms
273,380 KB
testcase_10 AC 1,772 ms
291,728 KB
testcase_11 AC 1,774 ms
294,560 KB
testcase_12 AC 1,770 ms
297,528 KB
testcase_13 AC 1,828 ms
304,028 KB
testcase_14 AC 1,795 ms
300,376 KB
testcase_15 AC 1,730 ms
305,520 KB
testcase_16 AC 1,706 ms
306,280 KB
testcase_17 AC 1,434 ms
319,360 KB
testcase_18 AC 1,939 ms
343,172 KB
testcase_19 AC 2,143 ms
347,956 KB
testcase_20 AC 1,546 ms
308,088 KB
testcase_21 AC 1,942 ms
336,980 KB
testcase_22 AC 2,035 ms
291,756 KB
testcase_23 AC 1,405 ms
308,148 KB
testcase_24 AC 41 ms
54,924 KB
testcase_25 AC 1,847 ms
306,132 KB
testcase_26 AC 1,790 ms
305,876 KB
testcase_27 AC 1,527 ms
306,040 KB
testcase_28 AC 1,657 ms
306,400 KB
testcase_29 AC 1,966 ms
322,104 KB
testcase_30 AC 1,783 ms
322,624 KB
testcase_31 AC 1,750 ms
321,580 KB
testcase_32 AC 1,702 ms
270,824 KB
testcase_33 AC 1,747 ms
271,544 KB
testcase_34 AC 1,487 ms
279,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

point = []
for _ in range(N):
    x,y = map(int,input().split())
    point.append((x,y))

def gcd(a,b):
    if b == 0:return a
    r = a % b
    a = b
    b = r
    return gcd(a,b)

from collections import defaultdict
d1 = defaultdict(int)
d2 = defaultdict(int)

ans = 0

for i in range(N):
    x,y = point[i]
    for j in range(i + 1,N):
        xx,yy = point[j]

        if xx == x:
            u = (0,1)
        elif yy == y:
            u = (1,0)
        elif xx > x:
            a = xx - x
            b = yy - y
            t = gcd(a,b if b > 0 else -b)
            u = (a // t,b // t)
        else:
            a = x - xx
            b = y - yy
            t = gcd(a,b if b > 0 else -b)
            u = (a // t,b // t)
        v = (x + xx,y + yy)

        """
        ans += d1[v]
        ans -= d2[(v,u)]
        d1[v] += 1
        d2[(v,u)] += 1
        """

        m,mm = u
        uu = (-mm,m)
        uuu = (mm,-m)
        ans += d2[(v,uu)]
        ans += d2[(v,uuu)]
        d2[(v,u)] += 1
        
print(ans)
#print(d1,d2)
0