답안 #888466

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
888466 2023-12-17T13:38:25 Z vjudge1 Airplane (NOI23_airplane) C++17
100 / 100
284 ms 28360 KB
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define int long long
int a[200005], f[200005], d[200005];
vector<int> g[200005];
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        f[i] = d[i] = -1;
    }
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    priority_queue<pair<int, int>> q;
    q.push({0, 1});
    f[1] = 0;
    while (!q.empty()) {
        pair<int, int> p = q.top();
        q.pop();
        int x = -p.first, u = p.second;
        for (int w : g[u]) {
            if (f[w] != -1) continue;
            f[w] = max(x + 1, a[w]);
            q.push({-f[w], w});
        }
    }
    q.push({0, n});
    d[n] = 0;
    while (!q.empty()) {
        pair<int, int> p = q.top();
        q.pop();
        int x = -p.first, u = p.second;
        for (int w : g[u]) {
            if (d[w] != -1) continue;
            d[w] = max(x + 1, a[w]);
            q.push({-d[w], w});
        }
    }
    int res = 1e9;
    for (int i = 1; i <= n; i++) {
        res = min(res, max(f[i], d[i]) * 2);
    }
    for (int i = 1; i <= n; i++) {
        for (int w : g[i]) {
            if (f[i] == d[w]) res = min(res, f[i] * 2 + 1);
        }
    }
    cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8792 KB Output is correct
2 Correct 57 ms 16016 KB Output is correct
3 Correct 59 ms 15956 KB Output is correct
4 Correct 60 ms 15952 KB Output is correct
5 Correct 61 ms 15952 KB Output is correct
6 Correct 61 ms 15952 KB Output is correct
7 Correct 61 ms 16036 KB Output is correct
8 Correct 1 ms 8792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8808 KB Output is correct
5 Correct 2 ms 8796 KB Output is correct
6 Correct 2 ms 8792 KB Output is correct
7 Correct 2 ms 8796 KB Output is correct
8 Correct 2 ms 8796 KB Output is correct
9 Correct 2 ms 8928 KB Output is correct
10 Correct 2 ms 8796 KB Output is correct
11 Correct 2 ms 8796 KB Output is correct
12 Correct 2 ms 8796 KB Output is correct
13 Correct 2 ms 9044 KB Output is correct
14 Correct 3 ms 8796 KB Output is correct
15 Correct 3 ms 9052 KB Output is correct
16 Correct 3 ms 9052 KB Output is correct
17 Correct 3 ms 8936 KB Output is correct
18 Correct 1 ms 8796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8808 KB Output is correct
5 Correct 2 ms 8796 KB Output is correct
6 Correct 2 ms 8792 KB Output is correct
7 Correct 2 ms 8796 KB Output is correct
8 Correct 2 ms 8796 KB Output is correct
9 Correct 2 ms 8928 KB Output is correct
10 Correct 2 ms 8796 KB Output is correct
11 Correct 2 ms 8796 KB Output is correct
12 Correct 2 ms 8796 KB Output is correct
13 Correct 2 ms 9044 KB Output is correct
14 Correct 3 ms 8796 KB Output is correct
15 Correct 3 ms 9052 KB Output is correct
16 Correct 3 ms 9052 KB Output is correct
17 Correct 3 ms 8936 KB Output is correct
18 Correct 1 ms 8796 KB Output is correct
19 Correct 3 ms 8796 KB Output is correct
20 Correct 2 ms 8796 KB Output is correct
21 Correct 2 ms 8796 KB Output is correct
22 Correct 3 ms 8796 KB Output is correct
23 Correct 2 ms 8796 KB Output is correct
24 Correct 2 ms 8792 KB Output is correct
25 Correct 3 ms 8796 KB Output is correct
26 Correct 4 ms 8948 KB Output is correct
27 Correct 3 ms 9048 KB Output is correct
28 Correct 4 ms 9052 KB Output is correct
29 Correct 3 ms 9052 KB Output is correct
30 Correct 3 ms 9052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8792 KB Output is correct
2 Correct 57 ms 16016 KB Output is correct
3 Correct 59 ms 15956 KB Output is correct
4 Correct 60 ms 15952 KB Output is correct
5 Correct 61 ms 15952 KB Output is correct
6 Correct 61 ms 15952 KB Output is correct
7 Correct 61 ms 16036 KB Output is correct
8 Correct 1 ms 8792 KB Output is correct
9 Correct 2 ms 8796 KB Output is correct
10 Correct 1 ms 8796 KB Output is correct
11 Correct 1 ms 8796 KB Output is correct
12 Correct 1 ms 8808 KB Output is correct
13 Correct 2 ms 8796 KB Output is correct
14 Correct 2 ms 8792 KB Output is correct
15 Correct 2 ms 8796 KB Output is correct
16 Correct 2 ms 8796 KB Output is correct
17 Correct 2 ms 8928 KB Output is correct
18 Correct 2 ms 8796 KB Output is correct
19 Correct 2 ms 8796 KB Output is correct
20 Correct 2 ms 8796 KB Output is correct
21 Correct 2 ms 9044 KB Output is correct
22 Correct 3 ms 8796 KB Output is correct
23 Correct 3 ms 9052 KB Output is correct
24 Correct 3 ms 9052 KB Output is correct
25 Correct 3 ms 8936 KB Output is correct
26 Correct 1 ms 8796 KB Output is correct
27 Correct 3 ms 8796 KB Output is correct
28 Correct 2 ms 8796 KB Output is correct
29 Correct 2 ms 8796 KB Output is correct
30 Correct 3 ms 8796 KB Output is correct
31 Correct 2 ms 8796 KB Output is correct
32 Correct 2 ms 8792 KB Output is correct
33 Correct 3 ms 8796 KB Output is correct
34 Correct 4 ms 8948 KB Output is correct
35 Correct 3 ms 9048 KB Output is correct
36 Correct 4 ms 9052 KB Output is correct
37 Correct 3 ms 9052 KB Output is correct
38 Correct 3 ms 9052 KB Output is correct
39 Correct 149 ms 19436 KB Output is correct
40 Correct 92 ms 19024 KB Output is correct
41 Correct 93 ms 18992 KB Output is correct
42 Correct 103 ms 19020 KB Output is correct
43 Correct 110 ms 19068 KB Output is correct
44 Correct 104 ms 19060 KB Output is correct
45 Correct 100 ms 19172 KB Output is correct
46 Correct 101 ms 19016 KB Output is correct
47 Correct 100 ms 19028 KB Output is correct
48 Correct 108 ms 18952 KB Output is correct
49 Correct 134 ms 19284 KB Output is correct
50 Correct 157 ms 19312 KB Output is correct
51 Correct 118 ms 19336 KB Output is correct
52 Correct 208 ms 24012 KB Output is correct
53 Correct 185 ms 23168 KB Output is correct
54 Correct 181 ms 23340 KB Output is correct
55 Correct 208 ms 23576 KB Output is correct
56 Correct 247 ms 27564 KB Output is correct
57 Correct 259 ms 27588 KB Output is correct
58 Correct 252 ms 28360 KB Output is correct
59 Correct 242 ms 24600 KB Output is correct
60 Correct 284 ms 24520 KB Output is correct
61 Correct 251 ms 24312 KB Output is correct
62 Correct 238 ms 24428 KB Output is correct
63 Correct 229 ms 24516 KB Output is correct
64 Correct 234 ms 24516 KB Output is correct
65 Correct 224 ms 24440 KB Output is correct
66 Correct 251 ms 24764 KB Output is correct
67 Correct 235 ms 24516 KB Output is correct