結果

問題 No.2769 Number of Rhombi
ユーザー nononnonon
提出日時 2024-05-31 22:05:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,575 ms / 5,000 ms
コード長 678 bytes
コンパイル時間 2,513 ms
コンパイル使用メモリ 214,784 KB
実行使用メモリ 97,152 KB
最終ジャッジ日時 2024-05-31 22:05:53
合計ジャッジ時間 44,540 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 944 ms
70,144 KB
testcase_04 AC 920 ms
62,464 KB
testcase_05 AC 807 ms
43,904 KB
testcase_06 AC 1,105 ms
54,912 KB
testcase_07 AC 1,432 ms
67,072 KB
testcase_08 AC 1,483 ms
69,760 KB
testcase_09 AC 1,519 ms
75,008 KB
testcase_10 AC 1,555 ms
82,048 KB
testcase_11 AC 1,555 ms
87,808 KB
testcase_12 AC 1,536 ms
91,904 KB
testcase_13 AC 1,493 ms
94,592 KB
testcase_14 AC 1,359 ms
96,384 KB
testcase_15 AC 1,350 ms
96,640 KB
testcase_16 AC 1,310 ms
96,768 KB
testcase_17 AC 1,261 ms
96,896 KB
testcase_18 AC 1,217 ms
97,152 KB
testcase_19 AC 1,162 ms
97,152 KB
testcase_20 AC 1,192 ms
97,024 KB
testcase_21 AC 1,179 ms
97,152 KB
testcase_22 AC 1,165 ms
97,152 KB
testcase_23 AC 1,171 ms
97,024 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 1,502 ms
94,592 KB
testcase_26 AC 1,441 ms
95,744 KB
testcase_27 AC 1,259 ms
97,024 KB
testcase_28 AC 1,330 ms
96,896 KB
testcase_29 AC 1,201 ms
97,024 KB
testcase_30 AC 1,304 ms
96,896 KB
testcase_31 AC 1,522 ms
91,904 KB
testcase_32 AC 1,522 ms
70,016 KB
testcase_33 AC 1,521 ms
69,888 KB
testcase_34 AC 1,575 ms
79,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
template<typename T>
T gcd(T a, T b){return b==0?a:gcd(b,a%b);}
int N,X[1010],Y[1010];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>N;
    for(int i=0;i<N;i++)cin>>X[i]>>Y[i];
    map<tuple<int,int,int,int>,int>mp;
    long ans=0;
    for(int i=0;i<N;i++)for(int j=0;j<i;j++)
    {
        int mx=X[i]+X[j],my=Y[i]+Y[j];
        int dx=X[i]-X[j],dy=Y[i]-Y[j];
        int g=gcd(abs(dx),abs(dy));
        dx/=g,dy/=g;
        if(dx<0)dx=-dx,dy=-dy;
        ans+=mp[make_tuple(mx,my,-dy,dx)];
        ans+=mp[make_tuple(mx,my,dy,-dx)];
        mp[make_tuple(mx,my,dx,dy)]++;
    }
    cout<<ans<<endl;
}
0