# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
570048 | 2022-05-28T13:41:08 Z | davi_bart | Ideal city (IOI12_city) | C++17 | 19 ms | 9888 KB |
#pragma GCC optimize("O3") #pragma GCC target("popcnt") #include <bits/stdc++.h> using namespace std; #define ll long long // #define int ll #define fi first #define se second #define pb push_back mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); static const int mod = 1e9; int N; vector<int> v[100010]; map<int, ll> ans[100010]; int DistanceSum(int n, int *X, int *Y) { N = n; int mi = X[0]; for (int i = 0; i < N; i++) { mi = min(mi, X[i]); } for (int i = 0; i < N; i++) { X[i] -= mi; v[X[i]].pb(Y[i]); } ll tot = 0; ll fatte = 0; for (int i = 0; i < N; i++) { if (v[i].size() == 0) break; sort(v[i].begin(), v[i].end()); for (int j = 0; j < v[i].size(); j++) { int prima = j; int dopo = v[i].size() - j - 1; ans[i][j] = prima * (prima + 1) / 2 + dopo * (dopo + 1) / 2; tot += dopo * (dopo + 1) / 2; if (i) { int cur = v[i][j]; cur = max(cur, v[i - 1][0]); cur = min(cur, v[i - 1].back()); tot += (ll)(1 + abs(v[i][j] - cur)) * fatte + ans[i - 1][cur]; ans[i][j] += (ll)(1 + abs(v[i][j] - cur)) * fatte + ans[i - 1][cur]; } ans[i][j] %= mod; tot %= mod; } fatte += v[i].size(); } return tot; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 7252 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 7416 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 19 ms | 9888 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 15 ms | 9856 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |