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>
#define ll long long
#define pb push_back
#define fi first
#define se second
using namespace std;
ll h, v, x[10005], y[10005], ans = 0;
map <ll, ll> mpx, mpy;
int main() {
    ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr);
    cin >> h >> v;
    for(int i = 1; i <= h; i++) {
        cin >> y[i];
    }
    for(int i = 1; i <= v; i++) {
        cin >> x[i];
    }
    for(int i = 1; i < h; i++) {
        for(int j = i + 1; j <= h; j++) {
            mpy[y[j] - y[i]]++;
        }
    }
    for(int i = 1; i < v; i++) {
        for(int j = i + 1; j <= v; j++) {
            mpx[x[j] - x[i]]++;
        }
    }
    for(auto u: mpx) {
        if(u.se) {
            ans += u.se * mpy[u.fi];
        }
    }
    cout << ans;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |