Submission #1099216

# Submission time Handle Problem Language Result Execution time Memory
1099216 2024-10-10T19:49:06 Z NoMercy Airplane (NOI23_airplane) C++17
32 / 100
1000 ms 19560 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
 
const ll inf = 1e18;

int32_t main () {

    ios_base::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0); 

    int N, M;
    cin >> N >> M;
    vector<int> h(N), g[N];
    vector<array<ll, 2>> dist(N);
    for (int i = 0;i < N;i ++) {
        cin >> h[i];
    }
    for (int i = 0;i < M;i ++) {
        int u, v; 
        cin >> u >> v;
        -- u;
        -- v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
 
    function<void(int, int)> dijikstra = [&](int si, int ti) -> void {
        for (int i = 0;i < N;i ++) {
            dist[i][ti] = inf;
        }
        dist[si][ti] = 0;
        multiset<array<ll, 2>> dj;
        dj.insert({dist[si][ti], si});
        while (dj.size() > 0) {
            auto [w, u] = *dj.begin();
            dj.erase(dj.begin());
            w = -w;
            if (w != dist[u][ti]) continue;
            for (auto v : g[u]) if (dist[v][ti] > max(1LL * h[v], dist[u][ti] + 1)) {
                dist[v][ti] = max(1LL * h[v], dist[u][ti] + 1);
                dj.insert({-dist[v][ti], v});
            }
        }
    };
    dijikstra(0, 0);
    dijikstra(N - 1, 1);

    ll ans = inf;
    for (int u = 0;u < N;u ++) {
        ans = min(ans, max(dist[u][0], dist[u][1]) * 2);
        for (auto v : g[u]) {
            ans = min(ans, max(dist[v][0], dist[u][1]) * 2 + 1);
            ans = min(ans, max(dist[u][0], dist[v][1]) * 2 + 1);
        }
    }
    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 57 ms 18516 KB Output is correct
3 Correct 62 ms 18724 KB Output is correct
4 Correct 67 ms 19104 KB Output is correct
5 Correct 61 ms 19540 KB Output is correct
6 Correct 60 ms 19540 KB Output is correct
7 Correct 60 ms 19560 KB Output is correct
8 Correct 0 ms 344 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 452 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 632 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 3 ms 604 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 9 ms 640 KB Output is correct
13 Correct 19 ms 604 KB Output is correct
14 Correct 91 ms 664 KB Output is correct
15 Correct 95 ms 700 KB Output is correct
16 Correct 66 ms 604 KB Output is correct
17 Correct 63 ms 604 KB Output is correct
18 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 452 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 632 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 3 ms 604 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 9 ms 640 KB Output is correct
13 Correct 19 ms 604 KB Output is correct
14 Correct 91 ms 664 KB Output is correct
15 Correct 95 ms 700 KB Output is correct
16 Correct 66 ms 604 KB Output is correct
17 Correct 63 ms 604 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 14 ms 600 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 26 ms 604 KB Output is correct
22 Correct 240 ms 604 KB Output is correct
23 Correct 11 ms 600 KB Output is correct
24 Correct 31 ms 604 KB Output is correct
25 Execution timed out 1029 ms 584 KB Time limit exceeded
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 57 ms 18516 KB Output is correct
3 Correct 62 ms 18724 KB Output is correct
4 Correct 67 ms 19104 KB Output is correct
5 Correct 61 ms 19540 KB Output is correct
6 Correct 60 ms 19540 KB Output is correct
7 Correct 60 ms 19560 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 452 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 632 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 3 ms 604 KB Output is correct
19 Correct 3 ms 604 KB Output is correct
20 Correct 9 ms 640 KB Output is correct
21 Correct 19 ms 604 KB Output is correct
22 Correct 91 ms 664 KB Output is correct
23 Correct 95 ms 700 KB Output is correct
24 Correct 66 ms 604 KB Output is correct
25 Correct 63 ms 604 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 14 ms 600 KB Output is correct
28 Correct 1 ms 600 KB Output is correct
29 Correct 26 ms 604 KB Output is correct
30 Correct 240 ms 604 KB Output is correct
31 Correct 11 ms 600 KB Output is correct
32 Correct 31 ms 604 KB Output is correct
33 Execution timed out 1029 ms 584 KB Time limit exceeded
34 Halted 0 ms 0 KB -