# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
267302 | taulant | Count Squares (CEOI19_countsquares) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int main(){
cin.tie(0)->sync_with_stdio(0);
int h, v; cin >> h >> v;
map<int, int> m, n;
vector<int> v(h), w(v);
for(int& i:v) cin >> i;
for(int& i:w) cin >> i;
for(int i=0; i<h; ++i) for(int j=i+1; j<h; ++j) ++m[v[j]-v[i]];
for(int i=0; i<v; ++i) for(int j=i+1; j<v; ++j) ++n[w[j]-w[i]];
int ans = 0;
for(auto& i:m) ans += i.second * n[i.first];
cout << ans << endl;
}