結果
| 問題 | No.2769 Number of Rhombi |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-01 15:23:02 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 782 ms / 5,000 ms |
| コード長 | 888 bytes |
| コンパイル時間 | 2,420 ms |
| コンパイル使用メモリ | 207,504 KB |
| 最終ジャッジ日時 | 2025-02-21 19:02:08 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr int MOD=998244353;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define replr(i,l,r) for(int i=(l);i<(int)(r);i++)
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin>>N;
vector P(N,array<ll,2>());
for(auto &i:P)cin>>i[0]>>i[1];
map<array<ll,4>,ll>cnt;
rep(i,N){
replr(j,i+1,N){
ll x=P[i][0]-P[j][0],y=P[i][1]-P[j][1],g=gcd(x,y);
x/=g,y/=g;
if(y<0)x*=-1,y*=-1;
if(x<0)x*=-1,y*=-1;
array<ll,4>a={P[i][0]+P[j][0],P[i][1]+P[j][1],x,y};
cnt[a]+=1;
}
}
ll ans=0;
for(auto i:cnt){
ll x=i.first[3],y=-i.first[2];
if(y<0)x*=-1,y*=-1;
if(x<0)x*=-1,y*=-1;
if(cnt.find(array<ll,4>({i.first[0],i.first[1],x,y}))!=cnt.end()){
ans+=i.second*cnt[array<ll,4>({i.first[0],i.first[1],x,y})];
}
}
cout<<ans/2<<'\n';
}