# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68564 | 2018-08-17T11:02:43 Z | BThero | Soccer (JOI17_soccer) | C++17 | 18 ms | 900 KB |
// Why I am so dumb? :c #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second using namespace std; typedef long long ll; const int MAXN = (int)1e3 + 5; const ll INF = (ll)1e16; int px[MAXN], py[MAXN]; bool u[MAXN]; int a, b, c; int n, m, k; ll d[MAXN]; ll ans; ll cost(int ax, int ay, int bx, int by) { int dx = abs(ax - bx), dy = abs(ay - by); ll ret = (dx + dy) * 1ll * c; ret = min(ret, dx * 1ll * c + dy * 1ll * a + b); ret = min(ret, dy * 1ll * c + dx * 1ll * a + b); return ret; } void solve() { scanf("%d %d", &n, &m); scanf("%d %d %d", &a, &b, &c); scanf("%d", &k); for (int i = 1; i <= k; ++i) { scanf("%d %d", &px[i], &py[i]); } if (k == 2) { printf("%lld\n", cost(px[1], py[1], px[2], py[2])); return; } for (int i = 2; i <= k; ++i) { d[i] = INF; } for (int i = 1; i <= k; ++i) { int v = -1; for (int j = 1; j <= k; ++j) { if (u[j]) { continue; } if (v == -1 || d[j] < d[v]) { v = j; } } if (d[v] == INF) { break; } u[v] = 1; for (int to = 1; to <= k; ++to) { if (to == v) { continue; } d[to] = min(d[to], d[v] + cost(px[v], py[v], px[to], py[to])); } } printf("%lld\n", d[k]); } int main() { int tt = 1; while (tt--) { solve(); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 472 KB | Output is correct |
3 | Correct | 2 ms | 564 KB | Output is correct |
4 | Correct | 3 ms | 564 KB | Output is correct |
5 | Correct | 2 ms | 564 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 564 KB | Output is correct |
2 | Correct | 3 ms | 720 KB | Output is correct |
3 | Correct | 2 ms | 720 KB | Output is correct |
4 | Correct | 3 ms | 736 KB | Output is correct |
5 | Correct | 3 ms | 736 KB | Output is correct |
6 | Correct | 14 ms | 736 KB | Output is correct |
7 | Correct | 14 ms | 812 KB | Output is correct |
8 | Correct | 15 ms | 836 KB | Output is correct |
9 | Correct | 18 ms | 836 KB | Output is correct |
10 | Correct | 13 ms | 836 KB | Output is correct |
11 | Correct | 14 ms | 900 KB | Output is correct |
12 | Correct | 4 ms | 900 KB | Output is correct |
13 | Correct | 14 ms | 900 KB | Output is correct |
14 | Correct | 14 ms | 900 KB | Output is correct |
15 | Correct | 13 ms | 900 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 472 KB | Output is correct |
3 | Correct | 2 ms | 564 KB | Output is correct |
4 | Correct | 3 ms | 564 KB | Output is correct |
5 | Correct | 2 ms | 564 KB | Output is correct |
6 | Correct | 2 ms | 564 KB | Output is correct |
7 | Correct | 3 ms | 720 KB | Output is correct |
8 | Correct | 2 ms | 720 KB | Output is correct |
9 | Correct | 3 ms | 736 KB | Output is correct |
10 | Correct | 3 ms | 736 KB | Output is correct |
11 | Correct | 14 ms | 736 KB | Output is correct |
12 | Correct | 14 ms | 812 KB | Output is correct |
13 | Correct | 15 ms | 836 KB | Output is correct |
14 | Correct | 18 ms | 836 KB | Output is correct |
15 | Correct | 13 ms | 836 KB | Output is correct |
16 | Correct | 14 ms | 900 KB | Output is correct |
17 | Correct | 4 ms | 900 KB | Output is correct |
18 | Correct | 14 ms | 900 KB | Output is correct |
19 | Correct | 14 ms | 900 KB | Output is correct |
20 | Correct | 13 ms | 900 KB | Output is correct |
21 | Correct | 4 ms | 900 KB | Output is correct |
22 | Incorrect | 3 ms | 900 KB | Output isn't correct |
23 | Halted | 0 ms | 0 KB | - |