# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
981586 | 2024-05-13T11:08:35 Z | kh0i | Count Squares (CEOI19_countsquares) | C++17 | 1904 ms | 141204 KB |
#include "bits/stdc++.h" using namespace std; #ifdef LOCAL #include "debug.h" #else #define debug(...) #endif using ll = long long; using pii = pair<int, int>; #define F first #define S second #define sz(x) (int)((x).size()) #define all(x) (x).begin(), (x).end() mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll get_rand(ll l, ll r) { assert(l <= r); return uniform_int_distribution<ll> (l, r)(rng); } void solve(){ int n, m; cin >> n >> m; vector<int> a(n), b(m); for(int i = 0; i < n; ++i) cin >> a[i]; for(int i = 0; i < m; ++i) cin >> b[i]; map<int, ll> mp; ll res = 0; for(int i = 0; i < n; ++i) for(int j = 0; j < i; ++j) ++mp[a[i] - a[j]]; for(int i = 0; i < m; ++i) for(int j = 0; j < i; ++j) res += mp[b[i] - b[j]]; cout << res; } int32_t main() { cin.tie(nullptr)->sync_with_stdio(0); #define task "troll" if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int test = 1; // cin >> test; for(int i = 1; i <= test; ++i){ // cout << "Case #" << i << ": "; solve(); } #ifdef LOCAL cerr << "\n[Time]: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n"; #endif return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 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 | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 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 | 124 ms | 22772 KB | Output is correct |
7 | Correct | 126 ms | 22920 KB | Output is correct |
8 | Correct | 158 ms | 22888 KB | Output is correct |
9 | Correct | 119 ms | 22124 KB | Output is correct |
10 | Correct | 7 ms | 860 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 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 | 124 ms | 22772 KB | Output is correct |
7 | Correct | 126 ms | 22920 KB | Output is correct |
8 | Correct | 158 ms | 22888 KB | Output is correct |
9 | Correct | 119 ms | 22124 KB | Output is correct |
10 | Correct | 7 ms | 860 KB | Output is correct |
11 | Correct | 1840 ms | 141092 KB | Output is correct |
12 | Correct | 1798 ms | 141128 KB | Output is correct |
13 | Correct | 1797 ms | 141204 KB | Output is correct |
14 | Correct | 1904 ms | 139076 KB | Output is correct |
15 | Correct | 71 ms | 1464 KB | Output is correct |