제출 #874364

#제출 시각아이디문제언어결과실행 시간메모리
874364bobbilykingCount Squares (CEOI19_countsquares)C++17
100 / 100
947 ms93752 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...