# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
108316 | 2019-04-28T13:58:18 Z | kek | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 221 ms | 263168 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; // #define int ll #define all(v) v.begin(), v.end() #define len(v) ((int)(v).size()) #define pb push_back #define kek pop_back #define pii pair<int, int> #define mp make_pair #define debug(x) cout << #x << " = " << x << endl; const int INF = 1e9 + 666; template<class t1, class t2> bool cmin(t1 &a, const t2 &b) { if (a > b) { a = b; return true; } return false; } template<class t1, class t2> bool cmax(t1 &a, const t2 &b) { if (a < b) { a = b; return true; } return false; } #ifndef LOCAL void UseFiles(const string &s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } #else void UseFiles(const string&) {} #endif void run(); signed main() { // UseFiles("cowboys"); iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0); run(); } void run() { int n, m; cin >> n >> m; vector<pii> doges(m); swap(n, m); for (auto &x : doges) { cin >> x.first >> x.second; } vector<vector<int>> g(n, vector<int>(n, INF)); for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if ((doges[i].first - doges[j].first) % doges[i].second == 0) { g[i][j] = abs((doges[i].first - doges[j].first) / doges[i].second); } } } vector<int> dist(n, INF); dist[0] = 0; priority_queue<pii, vector<pii>, greater<pii>> q; q.push({0, 0}); while (len(q)) { int d, v; tie(d, v) = q.top(); q.pop(); if (dist[v] != d) { continue; } for (int i = 0; i < n; ++i) { if (cmin(dist[i], d + g[v][i])) { q.push({dist[i], i}); } } } if (dist[1] == INF) { cout << -1 << endl; } else { cout << dist[1] << endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 300 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 428 KB | Output is correct |
10 | Correct | 5 ms | 1024 KB | Output is correct |
11 | Correct | 41 ms | 16124 KB | Output is correct |
12 | Correct | 34 ms | 16164 KB | Output is correct |
13 | Correct | 36 ms | 16128 KB | Output is correct |
14 | Correct | 35 ms | 16148 KB | Output is correct |
15 | Correct | 40 ms | 16248 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 3 ms | 1024 KB | Output is correct |
11 | Correct | 41 ms | 16128 KB | Output is correct |
12 | Correct | 42 ms | 16128 KB | Output is correct |
13 | Correct | 36 ms | 16128 KB | Output is correct |
14 | Correct | 37 ms | 16248 KB | Output is correct |
15 | Correct | 38 ms | 16128 KB | Output is correct |
16 | Correct | 8 ms | 3172 KB | Output is correct |
17 | Correct | 32 ms | 12800 KB | Output is correct |
18 | Correct | 9 ms | 4224 KB | Output is correct |
19 | Correct | 5 ms | 1536 KB | Output is correct |
20 | Correct | 40 ms | 16080 KB | Output is correct |
21 | Correct | 13 ms | 5760 KB | Output is correct |
22 | Correct | 7 ms | 2432 KB | Output is correct |
23 | Correct | 11 ms | 3968 KB | Output is correct |
24 | Correct | 34 ms | 14336 KB | Output is correct |
25 | Correct | 34 ms | 16128 KB | Output is correct |
26 | Correct | 38 ms | 16128 KB | Output is correct |
27 | Correct | 40 ms | 16128 KB | Output is correct |
28 | Correct | 34 ms | 16128 KB | Output is correct |
29 | Correct | 9 ms | 2560 KB | Output is correct |
30 | Correct | 2 ms | 512 KB | Output is correct |
31 | Correct | 6 ms | 1664 KB | Output is correct |
32 | Correct | 4 ms | 1280 KB | Output is correct |
33 | Correct | 37 ms | 16132 KB | Output is correct |
34 | Correct | 37 ms | 16248 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 428 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 3 ms | 512 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 1024 KB | Output is correct |
11 | Correct | 43 ms | 16140 KB | Output is correct |
12 | Correct | 35 ms | 16128 KB | Output is correct |
13 | Correct | 37 ms | 16128 KB | Output is correct |
14 | Correct | 39 ms | 16252 KB | Output is correct |
15 | Correct | 43 ms | 16248 KB | Output is correct |
16 | Correct | 9 ms | 3200 KB | Output is correct |
17 | Correct | 32 ms | 12800 KB | Output is correct |
18 | Correct | 9 ms | 4224 KB | Output is correct |
19 | Correct | 5 ms | 1536 KB | Output is correct |
20 | Correct | 38 ms | 16128 KB | Output is correct |
21 | Correct | 12 ms | 5760 KB | Output is correct |
22 | Correct | 6 ms | 2432 KB | Output is correct |
23 | Correct | 10 ms | 4096 KB | Output is correct |
24 | Correct | 34 ms | 14464 KB | Output is correct |
25 | Correct | 36 ms | 16128 KB | Output is correct |
26 | Correct | 39 ms | 16140 KB | Output is correct |
27 | Correct | 41 ms | 16128 KB | Output is correct |
28 | Correct | 41 ms | 16128 KB | Output is correct |
29 | Correct | 7 ms | 2560 KB | Output is correct |
30 | Correct | 2 ms | 512 KB | Output is correct |
31 | Correct | 6 ms | 1792 KB | Output is correct |
32 | Correct | 5 ms | 1280 KB | Output is correct |
33 | Correct | 39 ms | 16248 KB | Output is correct |
34 | Correct | 39 ms | 16232 KB | Output is correct |
35 | Runtime error | 221 ms | 263168 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
36 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 256 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 512 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 1024 KB | Output is correct |
11 | Correct | 38 ms | 16248 KB | Output is correct |
12 | Correct | 36 ms | 16248 KB | Output is correct |
13 | Correct | 35 ms | 16128 KB | Output is correct |
14 | Correct | 46 ms | 16248 KB | Output is correct |
15 | Correct | 35 ms | 16248 KB | Output is correct |
16 | Correct | 7 ms | 3200 KB | Output is correct |
17 | Correct | 31 ms | 12920 KB | Output is correct |
18 | Correct | 9 ms | 4224 KB | Output is correct |
19 | Correct | 4 ms | 1536 KB | Output is correct |
20 | Correct | 37 ms | 16128 KB | Output is correct |
21 | Correct | 13 ms | 5888 KB | Output is correct |
22 | Correct | 6 ms | 2432 KB | Output is correct |
23 | Correct | 12 ms | 4096 KB | Output is correct |
24 | Correct | 34 ms | 14336 KB | Output is correct |
25 | Correct | 40 ms | 16256 KB | Output is correct |
26 | Correct | 50 ms | 16128 KB | Output is correct |
27 | Correct | 50 ms | 16128 KB | Output is correct |
28 | Correct | 39 ms | 16100 KB | Output is correct |
29 | Correct | 7 ms | 2560 KB | Output is correct |
30 | Correct | 3 ms | 512 KB | Output is correct |
31 | Correct | 8 ms | 1664 KB | Output is correct |
32 | Correct | 5 ms | 1280 KB | Output is correct |
33 | Correct | 39 ms | 16248 KB | Output is correct |
34 | Correct | 34 ms | 16248 KB | Output is correct |
35 | Runtime error | 206 ms | 263168 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
36 | Halted | 0 ms | 0 KB | - |