Submission #887938

# Submission time Handle Problem Language Result Execution time Memory
887938 2023-12-15T14:25:51 Z Perl32 Jakarta Skyscrapers (APIO15_skyscraper) C++14
100 / 100
718 ms 4072 KB
//I wrote this code 4 u <3
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

const int INF = (int) 1e9 + 1e3;

signed main(int32_t argc, char *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> m >> n;
    vector<pair<int, int>> a(n);
    vector<vector<int>> g(m);
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second;
        g[a[i].first].push_back(a[i].second);
    }
    vector<int> dist(m, INF);
    set<pair<int, int>> st;
    st.insert({0, a[0].first});
    dist[a[0].first] = 0;
    while (!st.empty()) {
        auto [t, v] = *st.begin();
        st.erase(st.begin());
        for (auto jmp : g[v]) {
            int d = 0, cur = v;
            while (cur < m) {
                if (dist[cur] > dist[v] + d) {
                    st.erase({dist[cur], cur});
                    dist[cur] = dist[v] + d;
                    st.insert({dist[cur], cur});
                }
                cur += jmp;
                d++;
            }
            cur = v;
            d = 0;
            while (cur > -1) {
                if (dist[cur] > dist[v] + d) {
                    st.erase({dist[cur], cur});
                    dist[cur] = dist[v] + d;
                    st.insert({dist[cur], cur});
                }
                cur -= jmp;
                d++;
            }
        }
    }
    cout << (dist[a[1].first] == INF ? -1 : dist[a[1].first]);
}

/*

 */

Compilation message

skyscraper.cpp: In function 'int main(int32_t, char**)':
skyscraper.cpp:32:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   32 |         auto [t, v] = *st.begin();
      |              ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 452 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 352 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 456 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 452 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 452 KB Output is correct
3 Correct 1 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 1 ms 452 KB Output is correct
7 Correct 0 ms 356 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 456 KB Output is correct
11 Correct 1 ms 352 KB Output is correct
12 Correct 1 ms 352 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 1 ms 352 KB Output is correct
15 Correct 1 ms 552 KB Output is correct
16 Correct 0 ms 352 KB Output is correct
17 Correct 1 ms 500 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 4 ms 464 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 3 ms 552 KB Output is correct
27 Correct 3 ms 348 KB Output is correct
28 Correct 1 ms 472 KB Output is correct
29 Correct 3 ms 604 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
33 Correct 3 ms 604 KB Output is correct
34 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 4 ms 604 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 4 ms 348 KB Output is correct
27 Correct 3 ms 344 KB Output is correct
28 Correct 1 ms 856 KB Output is correct
29 Correct 3 ms 604 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 3 ms 604 KB Output is correct
34 Correct 3 ms 472 KB Output is correct
35 Correct 5 ms 1364 KB Output is correct
36 Correct 2 ms 604 KB Output is correct
37 Correct 5 ms 860 KB Output is correct
38 Correct 6 ms 1116 KB Output is correct
39 Correct 6 ms 1116 KB Output is correct
40 Correct 6 ms 1116 KB Output is correct
41 Correct 6 ms 1112 KB Output is correct
42 Correct 45 ms 1116 KB Output is correct
43 Correct 45 ms 1188 KB Output is correct
44 Correct 44 ms 1112 KB Output is correct
45 Correct 6 ms 1112 KB Output is correct
46 Correct 6 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 456 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 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 464 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 4 ms 604 KB Output is correct
21 Correct 0 ms 464 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 464 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 4 ms 348 KB Output is correct
27 Correct 3 ms 348 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 3 ms 604 KB Output is correct
30 Correct 1 ms 456 KB Output is correct
31 Correct 2 ms 620 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 3 ms 604 KB Output is correct
34 Correct 3 ms 856 KB Output is correct
35 Correct 5 ms 984 KB Output is correct
36 Correct 2 ms 604 KB Output is correct
37 Correct 5 ms 860 KB Output is correct
38 Correct 6 ms 1116 KB Output is correct
39 Correct 6 ms 1116 KB Output is correct
40 Correct 7 ms 1112 KB Output is correct
41 Correct 6 ms 1116 KB Output is correct
42 Correct 45 ms 1116 KB Output is correct
43 Correct 45 ms 1116 KB Output is correct
44 Correct 45 ms 1116 KB Output is correct
45 Correct 6 ms 1116 KB Output is correct
46 Correct 6 ms 1116 KB Output is correct
47 Correct 20 ms 2136 KB Output is correct
48 Correct 5 ms 1884 KB Output is correct
49 Correct 5 ms 1972 KB Output is correct
50 Correct 4 ms 1628 KB Output is correct
51 Correct 36 ms 3672 KB Output is correct
52 Correct 34 ms 3416 KB Output is correct
53 Correct 14 ms 3676 KB Output is correct
54 Correct 3 ms 1820 KB Output is correct
55 Correct 4 ms 1880 KB Output is correct
56 Correct 673 ms 4072 KB Output is correct
57 Correct 75 ms 2768 KB Output is correct
58 Correct 718 ms 2456 KB Output is correct
59 Correct 626 ms 2644 KB Output is correct
60 Correct 674 ms 2556 KB Output is correct
61 Correct 561 ms 2392 KB Output is correct
62 Correct 8 ms 2652 KB Output is correct
63 Correct 50 ms 3344 KB Output is correct
64 Correct 50 ms 3160 KB Output is correct
65 Correct 60 ms 3336 KB Output is correct
66 Correct 83 ms 3164 KB Output is correct
67 Correct 82 ms 3164 KB Output is correct