| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 422908 | Andyvanh1 | Count Squares (CEOI19_countsquares) | C++14 | 1210 ms | 97728 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;
 
#define vt vector
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,x) for(int (i) = 0; (i) < (x); (i)++ )
 
typedef long long ll;
typedef long double ld;
typedef vt<int> vi;
typedef pair<int,int> pii;
 
unordered_map<int,int> mp1;
unordered_map<int,int> mp2;
 
 
void solve(){
    int n, m;
    cin>>n>>m;
    vi arr1(n);
    vi arr2(m);
    rep(i,n)cin>>arr1[i];
    rep(i,m)cin>>arr2[i];
    vt<int> vec;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            int x = arr1[j]-arr1[i];
            if(mp1.find(x)==mp1.end()){
                mp1[x] = 1;
                vec.pb(x);
            }else{
                mp1[x]++;
            }
        }
    }
    for(int i = 0; i < m; i++){
        for(int j = i+1; j < m; j++){
            int x = arr2[j]-arr2[i];
            if(mp2.find(x)==mp2.end()){
                mp2[x] = 1;
            }else{
                mp2[x]++;
            }
        }
    }
    ll ans = 0;
    for(auto& e: vec){
        if(mp2.find(e)!=mp2.end()){
            ans+= 1ll*mp2[e]*mp1[e];
        }
    }
    cout<<ans<<'\n';
 
 
}
 
 
int main(){
    solve();
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
