# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
422908 | 2021-06-10T13:56:56 Z | Andyvanh1 | Count Squares (CEOI19_countsquares) | C++14 | 1210 ms | 97728 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 105 ms | 18868 KB | Output is correct |
7 | Correct | 103 ms | 18804 KB | Output is correct |
8 | Correct | 117 ms | 18824 KB | Output is correct |
9 | Correct | 112 ms | 15972 KB | Output is correct |
10 | Correct | 13 ms | 588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 105 ms | 18868 KB | Output is correct |
7 | Correct | 103 ms | 18804 KB | Output is correct |
8 | Correct | 117 ms | 18824 KB | Output is correct |
9 | Correct | 112 ms | 15972 KB | Output is correct |
10 | Correct | 13 ms | 588 KB | Output is correct |
11 | Correct | 1147 ms | 97728 KB | Output is correct |
12 | Correct | 1210 ms | 97728 KB | Output is correct |
13 | Correct | 1129 ms | 97604 KB | Output is correct |
14 | Correct | 1141 ms | 96632 KB | Output is correct |
15 | Correct | 72 ms | 960 KB | Output is correct |