Submission #605763

# Submission time Handle Problem Language Result Execution time Memory
605763 2022-07-26T01:44:11 Z ukraine Count Squares (CEOI19_countsquares) C++17
100 / 100
1709 ms 211288 KB
#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
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 131 ms 33996 KB Output is correct
7 Correct 132 ms 33956 KB Output is correct
8 Correct 141 ms 33948 KB Output is correct
9 Correct 142 ms 32744 KB Output is correct
10 Correct 10 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 131 ms 33996 KB Output is correct
7 Correct 132 ms 33956 KB Output is correct
8 Correct 141 ms 33948 KB Output is correct
9 Correct 142 ms 32744 KB Output is correct
10 Correct 10 ms 852 KB Output is correct
11 Correct 1707 ms 211288 KB Output is correct
12 Correct 1704 ms 211260 KB Output is correct
13 Correct 1709 ms 211180 KB Output is correct
14 Correct 1666 ms 208204 KB Output is correct
15 Correct 66 ms 1900 KB Output is correct