結果

問題 No.2769 Number of Rhombi
ユーザー 👑 timitimi
提出日時 2024-06-04 00:16:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,076 ms / 5,000 ms
コード長 820 bytes
コンパイル時間 579 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 241,028 KB
最終ジャッジ日時 2024-06-04 00:17:10
合計ジャッジ時間 30,288 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,096 KB
testcase_01 AC 38 ms
52,224 KB
testcase_02 AC 42 ms
57,472 KB
testcase_03 AC 978 ms
209,276 KB
testcase_04 AC 836 ms
191,100 KB
testcase_05 AC 656 ms
151,940 KB
testcase_06 AC 828 ms
171,104 KB
testcase_07 AC 1,008 ms
205,784 KB
testcase_08 AC 1,076 ms
206,236 KB
testcase_09 AC 1,022 ms
209,292 KB
testcase_10 AC 922 ms
224,020 KB
testcase_11 AC 915 ms
221,208 KB
testcase_12 AC 897 ms
224,472 KB
testcase_13 AC 876 ms
239,084 KB
testcase_14 AC 873 ms
240,244 KB
testcase_15 AC 950 ms
240,208 KB
testcase_16 AC 830 ms
240,760 KB
testcase_17 AC 865 ms
240,268 KB
testcase_18 AC 827 ms
240,844 KB
testcase_19 AC 856 ms
240,536 KB
testcase_20 AC 861 ms
240,712 KB
testcase_21 AC 839 ms
240,400 KB
testcase_22 AC 850 ms
241,028 KB
testcase_23 AC 877 ms
240,684 KB
testcase_24 AC 39 ms
52,224 KB
testcase_25 AC 880 ms
238,992 KB
testcase_26 AC 901 ms
240,584 KB
testcase_27 AC 899 ms
237,688 KB
testcase_28 AC 860 ms
240,448 KB
testcase_29 AC 867 ms
240,560 KB
testcase_30 AC 841 ms
240,268 KB
testcase_31 AC 903 ms
224,580 KB
testcase_32 AC 1,016 ms
206,472 KB
testcase_33 AC 1,002 ms
206,264 KB
testcase_34 AC 961 ms
223,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
N=int(input())
A=[];D={};E={};F={}
for i in range(N):
  x,y=map(int, input().split())
  A.append((x,y))
  
  
cc=0
for i in range(N-1):
  for j in range(i+1,N):
    cc+=1
    ax,ay=A[i];bx,by=A[j]
    #x,y:中点
    x,y=(ax+bx),(ay+by)
    xx,yy=ax-bx,ay-by 
    if xx==0:
      if (x,y) not in E:
        E[(x,y)]=0
      E[x,y]+=1
    elif yy==0:
      if (x,y) not in F:
        F[(x,y)]=0
      F[x,y]+=1
    else:
      c=math.gcd(abs(xx),abs(yy))
      xx//=c;yy//=c
      if xx<0:
        xx*=-1;yy*=-1 
      if (xx,yy,x,y) not in D:
        D[(xx,yy,x,y)]=0
      D[(xx,yy,x,y)]+=1 


ansa=0
for x,y in E:
  if (x,y) in F:
    ansa+=E[(x,y)]*F[(x,y)]

ansb=0
for xx,yy,x,y in D:
  p,q=-yy,xx
  if p<0:
    p*=-1;q*=-1 
  if (p,q,x,y) in D:
    ansb+=D[(p,q,x,y)]*D[(xx,yy,x,y)]
print(ansa+ansb//2)
0