Submission #969746

# Submission time Handle Problem Language Result Execution time Memory
969746 2024-04-25T14:17:53 Z Pring Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 106712 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif

#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;

const int MXN = 30000, MXM = 10000005, INF = 1e9;
int n, m;
vector<int> pos, p;
map<pii, int> M;

namespace GRAPH {
    vector<int> bck[MXN];
    unordered_map<int, int> dis;
    unordered_map<int, bool> b;
    deque<int> dq;

    void ZOBFS(int sr, int to) {
        auto PUSH = [&](int id) -> void {
            debug(id, dis[id]);
            auto PUT = [&](int i, int id, int w) -> void {
                if (b[i]) return;
                if (dis.find(i) == dis.end() || dis[i] < dis[id] + w) {
                    dis[i] = dis[id] + w;
                    if (w) dq.push_back(i);
                    else dq.push_front(i);
                }
            };
            if (id < n) {
                for (auto &i : bck[id]) PUT(i + n, id, 0);
                return;
            }
            if (id < n + m) {
                PUT(pos[id - n], id, 0);
                PUT(pos[id - n] * MXN + p[id - n] + n + m, id, 0);
                return;
            }
            id -= (n + m);
            int now = id / MXN, mod = id % MXN;
            PUT(now, id + n + m, 0);
            if (now - mod >= 0) PUT((now - mod) * MXN + mod + n + m, id + n + m, 1);
            if (now + mod < n) PUT((now + mod) * MXN + mod + n + m, id + n + m, 1);
        };
        dis[sr] = 0;
        dq.push_back(sr);
        while (dq.size()) {
            int id = dq.front();
            dq.pop_front();
            if (b[id]) continue;
            b[id] = true;
            PUSH(id);
            if (dis.find(to) != dis.end()) break;
        }
    }
}

int minimum_jumps(int N, int M, vector<int> &B, vector<int> &P) {
    using namespace GRAPH;
    n = N;
    m = M;
    pos = B;
    p = P;
    FOR(i, 0, m) bck[B[i]].push_back(i);
    ZOBFS(n, n + 1);
    if (dis.find(n + 1) == dis.end()) return -1;
    return dis[n + 1];
}

void miku() {
    int n, m;
    cin >> n >> m;
    vector<int> b(m), p(m);
    FOR(i, 0, m) cin >> b[i] >> p[i];
    cout << minimum_jumps(n, m, b, p) << '\n';
}

int32_t main() {
    cin.tie(0) -> sync_with_stdio(false);
    cin.exceptions(cin.failbit);
    miku();
    return 0;
}

Compilation message

skyscraper.cpp: In lambda function:
skyscraper.cpp:11:20: warning: statement has no effect [-Wunused-value]
   11 | #define debug(...) 39
      |                    ^~
skyscraper.cpp:34:13: note: in expansion of macro 'debug'
   34 |             debug(id, dis[id]);
      |             ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1368 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 0 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1112 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 2 ms 1884 KB Output is correct
15 Correct 2 ms 1576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 2 ms 1372 KB Output is correct
14 Correct 2 ms 1880 KB Output is correct
15 Correct 2 ms 1628 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 2 ms 1628 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1112 KB Output is correct
20 Correct 2 ms 1628 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1312 KB Output is correct
23 Correct 2 ms 1628 KB Output is correct
24 Correct 3 ms 1884 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 2 ms 1372 KB Output is correct
27 Correct 2 ms 1628 KB Output is correct
28 Correct 8 ms 3512 KB Output is correct
29 Correct 16 ms 6268 KB Output is correct
30 Correct 4 ms 2648 KB Output is correct
31 Correct 9 ms 3860 KB Output is correct
32 Correct 7 ms 3296 KB Output is correct
33 Correct 31 ms 11576 KB Output is correct
34 Correct 17 ms 6776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1368 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 2 ms 1884 KB Output is correct
15 Correct 2 ms 1628 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 2 ms 1624 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 2 ms 1624 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 2 ms 1628 KB Output is correct
24 Correct 3 ms 1884 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 2 ms 1372 KB Output is correct
27 Correct 3 ms 1884 KB Output is correct
28 Correct 6 ms 3348 KB Output is correct
29 Correct 17 ms 6296 KB Output is correct
30 Correct 4 ms 2652 KB Output is correct
31 Correct 9 ms 4056 KB Output is correct
32 Correct 7 ms 3300 KB Output is correct
33 Correct 30 ms 11512 KB Output is correct
34 Correct 17 ms 6780 KB Output is correct
35 Correct 22 ms 7804 KB Output is correct
36 Correct 2 ms 1368 KB Output is correct
37 Correct 16 ms 5996 KB Output is correct
38 Correct 13 ms 4776 KB Output is correct
39 Correct 5 ms 1880 KB Output is correct
40 Correct 7 ms 2908 KB Output is correct
41 Correct 10 ms 3196 KB Output is correct
42 Correct 4 ms 2108 KB Output is correct
43 Correct 9 ms 4656 KB Output is correct
44 Correct 10 ms 4624 KB Output is correct
45 Correct 255 ms 44848 KB Output is correct
46 Correct 117 ms 26012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 1 ms 1400 KB Output is correct
14 Correct 3 ms 1884 KB Output is correct
15 Correct 2 ms 1628 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 3 ms 1624 KB Output is correct
18 Correct 1 ms 1112 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 2 ms 1628 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1112 KB Output is correct
23 Correct 2 ms 1628 KB Output is correct
24 Correct 3 ms 1884 KB Output is correct
25 Correct 1 ms 1112 KB Output is correct
26 Correct 1 ms 1372 KB Output is correct
27 Correct 3 ms 1884 KB Output is correct
28 Correct 6 ms 3348 KB Output is correct
29 Correct 18 ms 6464 KB Output is correct
30 Correct 4 ms 2652 KB Output is correct
31 Correct 13 ms 3960 KB Output is correct
32 Correct 7 ms 3348 KB Output is correct
33 Correct 31 ms 11588 KB Output is correct
34 Correct 17 ms 6736 KB Output is correct
35 Correct 23 ms 7792 KB Output is correct
36 Correct 2 ms 1372 KB Output is correct
37 Correct 16 ms 6212 KB Output is correct
38 Correct 13 ms 5136 KB Output is correct
39 Correct 4 ms 1884 KB Output is correct
40 Correct 7 ms 2840 KB Output is correct
41 Correct 9 ms 3224 KB Output is correct
42 Correct 4 ms 2140 KB Output is correct
43 Correct 10 ms 4628 KB Output is correct
44 Correct 10 ms 4628 KB Output is correct
45 Correct 261 ms 44832 KB Output is correct
46 Correct 111 ms 26024 KB Output is correct
47 Correct 11 ms 4368 KB Output is correct
48 Correct 5 ms 2068 KB Output is correct
49 Correct 4 ms 1708 KB Output is correct
50 Correct 3 ms 1624 KB Output is correct
51 Correct 34 ms 10976 KB Output is correct
52 Correct 37 ms 11576 KB Output is correct
53 Correct 9 ms 3416 KB Output is correct
54 Correct 6 ms 3604 KB Output is correct
55 Correct 10 ms 5320 KB Output is correct
56 Correct 27 ms 11128 KB Output is correct
57 Correct 1 ms 1112 KB Output is correct
58 Correct 33 ms 12356 KB Output is correct
59 Correct 26 ms 10456 KB Output is correct
60 Correct 26 ms 10456 KB Output is correct
61 Correct 28 ms 11332 KB Output is correct
62 Correct 420 ms 45424 KB Output is correct
63 Execution timed out 1030 ms 106712 KB Time limit exceeded
64 Halted 0 ms 0 KB -