# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
422907 | 2021-06-10T13:55:59 Z | Andyvanh1 | Count Squares (CEOI19_countsquares) | C++14 | 2740 ms | 110272 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; map<int,int> mp1; 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 292 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 292 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 202 ms | 17820 KB | Output is correct |
7 | Correct | 214 ms | 17848 KB | Output is correct |
8 | Correct | 216 ms | 17776 KB | Output is correct |
9 | Correct | 196 ms | 17300 KB | Output is correct |
10 | Correct | 23 ms | 588 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 292 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 202 ms | 17820 KB | Output is correct |
7 | Correct | 214 ms | 17848 KB | Output is correct |
8 | Correct | 216 ms | 17776 KB | Output is correct |
9 | Correct | 196 ms | 17300 KB | Output is correct |
10 | Correct | 23 ms | 588 KB | Output is correct |
11 | Correct | 2735 ms | 110264 KB | Output is correct |
12 | Correct | 2562 ms | 110272 KB | Output is correct |
13 | Correct | 2604 ms | 110196 KB | Output is correct |
14 | Correct | 2740 ms | 108812 KB | Output is correct |
15 | Correct | 167 ms | 1092 KB | Output is correct |