Submission #874364

# Submission time Handle Problem Language Result Execution time Memory
874364 2023-11-16T18:09:24 Z bobbilyking Count Squares (CEOI19_countsquares) C++17
100 / 100
947 ms 93752 KB
#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include<bits/stdc++.h>
#include<math.h>
using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pl;

#define K first
#define V second
#define G(x) ll x; cin >> x;
#define GD(x) ld x; cin >> x;
#define GS(s) string s; cin >> s;
#define EX(x) { cout << x << '\n'; exit(0); }
#define A(a) (a).begin(), (a).end()
#define F(i, l, r) for (ll i = (l); i < r; ++i)

#define NN
#define M 1000000007 // 998244353


int main(){
//    freopen("a.in", "r", stdin);
//    freopen("a.out", "w", stdout);

    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(20);
    G(h) G(v)
    vector<ll> y(v);    
    vector<ll> x(h);
    for (auto &y: x) cin >> y;
    for (auto &x: y) cin >> x;
    sort(A(x)); sort(A(y));
    unordered_map<ll, ll> cnt;
    F(i, 0, v) F(j, i+1, v) cnt[y[j]-y[i]]++;
    ll ans = 0;
    F(i, 0, h) F(j, i+1, h) ans += cnt[x[j]-x[i]];
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 58 ms 19656 KB Output is correct
7 Correct 60 ms 19572 KB Output is correct
8 Correct 58 ms 19580 KB Output is correct
9 Correct 42 ms 13952 KB Output is correct
10 Correct 5 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 58 ms 19656 KB Output is correct
7 Correct 60 ms 19572 KB Output is correct
8 Correct 58 ms 19580 KB Output is correct
9 Correct 42 ms 13952 KB Output is correct
10 Correct 5 ms 600 KB Output is correct
11 Correct 944 ms 93752 KB Output is correct
12 Correct 945 ms 93700 KB Output is correct
13 Correct 919 ms 93680 KB Output is correct
14 Correct 947 ms 92928 KB Output is correct
15 Correct 24 ms 1116 KB Output is correct