#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll i,j,h,v,x[2000],y[2000],ans;
map<ll,ll> mp1,mp2;
int main(){
cin >> h >> v;
for(i=1;i<=h;i++){
cin >> y[i];
}
for(i=1;i<=v;i++){
cin >> x[i];
}
for(i=1;i<=h;i++){
for(j=i+1;j<=h;j++)
mp1[y[j]-y[i]]++;
}
for(i=1;i<=v;i++){
for(j=i+1;j<=v;j++)
mp2[x[j]-x[i]]++;
}
for(auto [a,b]:mp1){
ans+=(b*mp2[a]);
}
cout << ans;
}
Compilation message
countsquares.cpp: In function 'int main()':
countsquares.cpp:22:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
22 | for(auto [a,b]:mp1){
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Correct |
124 ms |
33996 KB |
Output is correct |
7 |
Correct |
155 ms |
33876 KB |
Output is correct |
8 |
Correct |
126 ms |
33960 KB |
Output is correct |
9 |
Correct |
123 ms |
33108 KB |
Output is correct |
10 |
Correct |
11 ms |
860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Correct |
124 ms |
33996 KB |
Output is correct |
7 |
Correct |
155 ms |
33876 KB |
Output is correct |
8 |
Correct |
126 ms |
33960 KB |
Output is correct |
9 |
Correct |
123 ms |
33108 KB |
Output is correct |
10 |
Correct |
11 ms |
860 KB |
Output is correct |
11 |
Correct |
1466 ms |
211312 KB |
Output is correct |
12 |
Correct |
1414 ms |
211084 KB |
Output is correct |
13 |
Correct |
1385 ms |
211476 KB |
Output is correct |
14 |
Correct |
1433 ms |
209236 KB |
Output is correct |
15 |
Correct |
97 ms |
1880 KB |
Output is correct |