結果

問題 No.2769 Number of Rhombi
ユーザー 👑 kmjpkmjp
提出日時 2024-05-31 23:07:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,204 ms / 5,000 ms
コード長 1,504 bytes
コンパイル時間 2,425 ms
コンパイル使用メモリ 213,072 KB
実行使用メモリ 81,536 KB
最終ジャッジ日時 2024-05-31 23:08:32
合計ジャッジ時間 35,180 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 656 ms
57,088 KB
testcase_04 AC 630 ms
49,920 KB
testcase_05 AC 559 ms
34,816 KB
testcase_06 AC 791 ms
43,520 KB
testcase_07 AC 1,060 ms
53,120 KB
testcase_08 AC 1,047 ms
55,680 KB
testcase_09 AC 1,118 ms
60,544 KB
testcase_10 AC 1,166 ms
67,200 KB
testcase_11 AC 1,175 ms
72,448 KB
testcase_12 AC 1,204 ms
76,544 KB
testcase_13 AC 1,163 ms
79,104 KB
testcase_14 AC 1,122 ms
81,024 KB
testcase_15 AC 1,091 ms
81,024 KB
testcase_16 AC 1,068 ms
81,152 KB
testcase_17 AC 1,040 ms
81,408 KB
testcase_18 AC 983 ms
81,408 KB
testcase_19 AC 979 ms
81,536 KB
testcase_20 AC 976 ms
81,408 KB
testcase_21 AC 951 ms
81,536 KB
testcase_22 AC 970 ms
81,408 KB
testcase_23 AC 914 ms
81,536 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 1,150 ms
79,232 KB
testcase_26 AC 1,099 ms
80,256 KB
testcase_27 AC 1,004 ms
81,280 KB
testcase_28 AC 1,049 ms
81,152 KB
testcase_29 AC 957 ms
81,408 KB
testcase_30 AC 1,067 ms
81,280 KB
testcase_31 AC 1,157 ms
76,544 KB
testcase_32 AC 1,080 ms
56,192 KB
testcase_33 AC 1,046 ms
55,936 KB
testcase_34 AC 1,133 ms
64,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N;
ll X[1010],Y[1010];

map<pair<pair<ll,ll>,pair<ll,ll>>,int> M;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	ll ret=0;
	FOR(i,N) {
		cin>>X[i]>>Y[i];
		FOR(j,i) {
			ll sx=X[i]+X[j];
			ll sy=Y[i]+Y[j];
			ll dx=X[i]-X[j];
			ll dy=Y[i]-Y[j];
			if(dx<0) {
				dx=-dx;
				dy=-dy;
			}
			if(dx==0) dy=abs(dy);
			ll g=__gcd(abs(dx),abs(dy));
			dx/=g;
			dy/=g;
			M[{{sx,sy},{dx,dy}}]++;
			
			if(dx==0) {
				ret+=M[{{sx,sy},{1,0}}];
			}
			else if(dy==0) {
				ret+=M[{{sx,sy},{0,1}}];
			}
			else {
				swap(dx,dy);
				dx=-dx;
				if(dx<0) {
					dx=-dx;
					dy=-dy;
				}
				if(dx==0) dy=abs(dy);
				
				ret+=M[{{sx,sy},{dx,dy}}];
			}
			
		}
		
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0