Source Code
Problem: 2785 User: liangrx06
Memory: 49276K Time: 7016MS
Language: C++ Result: Accepted
Source Code
#include <iostream>#include <cstdio>#include <algorithm>usingnamespacestd;
constint N = 4000;
int n, m;
int a[4][N];
int x[N*N], y[N*N];
int main(void)
{
cin >> n;
m = n*n;
for (int i = 0; i < n; i ++)
for (int j = 0; j < 4; j ++)
scanf("%d", &a[j][i]);
for (int i = 0; i < n; i ++)
for (int j = 0; j < n; j ++)
x[i*n+j] = a[0][i] + a[1][j];
for (int i = 0; i < n; i ++)
for (int j = 0; j < n; j ++)
y[i*n+j] = a[2][i] + a[3][j];
sort(y, y+m);
longlong ans = 0;
for (int i = 0; i < m; i ++)
ans += (upper_bound(y, y+m, -x[i]) - lower_bound(y, y+m, -x[i]));
printf("%lld\n", ans);
return0;