-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp1479.cpp
More file actions
49 lines (47 loc) · 1.09 KB
/
p1479.cpp
File metadata and controls
49 lines (47 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include<iostream>
#include<map>
using namespace std;
int A[2001];
int B[2001];
int C[2001];
int D[2001];
int main(){
int t;
cin>>t;
while(t--){
int n;
cin>>n;
for(int i=0;i<n;i++){
cin>>A[i]>>B[i]>>C[i]>>D[i];
}
map<int,int> m;
int r;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
r=A[i]+B[j];
if(m.find(r)!=m.end()){
m[r]++;
}else{
m.insert(pair<int, int> (r, 1));//c++ map使用,插入操作
}
}
}
// map<int, int>::iterator iter;
// iter = m.begin();
// while(iter != m.end()) {
// cout << iter->first << " : " << iter->second << endl;
// iter++;
// }
int sum=0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
r=C[i]+D[j];
if(m.find(-r)!=m.end()){
sum=sum+m[-r];
}
}
}
cout<<sum<<endl;
// system("pause");
}
}