Submission #1275322

#TimeUsernameProblemLanguageResultExecution timeMemory
1275322sh1ftAirplane (NOI23_airplane)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int mxN = 2e5+5;

int n, m;
ll a[mxN], dis[mxN], ans = LLONG_MAX;
vector <int> adj[mxN];

int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 0, u, v; i < m; i++) cin >> u >> v, adj[u].emplace_back(v), adj[v].emplace_back(u);
    priority_queue <tuple <ll, ll, ll, int>> q;
    q.emplace(0, 0, 0, 1);
    for (int i = 2; i <= n; i++) dis[i] = LLONG_MAX;
    while (!q.empty()) {
        auto [t, L, R, u] = q.top(); q.pop();
        if (u == n) { ans = min(ans, (-t) + R); continue; }
        for (auto v : adj[u]) {
            ll w = 1, l = L+1, r = R;
            if (a[v] > l) w += a[v] - l, l = a[v];
            r--;
            r = max(r, a[v]);
            if (dis[v] > dis[u] + w) q.emplace(-(dis[v] = dis[u] + w), l, r, v);
        }
    }
    cout << ans << '\n';
}#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int mxN = 2e5+5;

int n, m;
ll a[mxN], dis[mxN], ans = LLONG_MAX;
vector <int> adj[mxN];

int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 0, u, v; i < m; i++) cin >> u >> v, adj[u].emplace_back(v), adj[v].emplace_back(u);
    priority_queue <tuple <ll, ll, ll, int>> q;
    q.emplace(0, 0, 0, 1);
    for (int i = 2; i <= n; i++) dis[i] = LLONG_MAX;
    while (!q.empty()) {
        auto [t, L, R, u] = q.top(); q.pop();
        if (u == n) { ans = min(ans, (-t) + R); continue; }
        for (auto v : adj[u]) {
            ll w = 1, l = L+1, r = R;
            if (a[v] > l) w += a[v] - l, l = a[v];
            r--;
            r = max(r, a[v]);
            if (dis[v] > dis[u] + w) q.emplace(-(dis[v] = dis[u] + w), l, r, v);
        }
    }
    cout << ans << '\n';
}

Compilation message (stderr)

Main.cpp:31:2: error: stray '#' in program
   31 | }#include <bits/stdc++.h>
      |  ^
Main.cpp:31:3: error: 'include' does not name a type
   31 | }#include <bits/stdc++.h>
      |   ^~~~~~~
Main.cpp:36:11: error: redefinition of 'const int mxN'
   36 | const int mxN = 2e5+5;
      |           ^~~
Main.cpp:6:11: note: 'const int mxN' previously defined here
    6 | const int mxN = 2e5+5;
      |           ^~~
Main.cpp:38:5: error: redefinition of 'int n'
   38 | int n, m;
      |     ^
Main.cpp:8:5: note: 'int n' previously declared here
    8 | int n, m;
      |     ^
Main.cpp:38:8: error: redefinition of 'int m'
   38 | int n, m;
      |        ^
Main.cpp:8:8: note: 'int m' previously declared here
    8 | int n, m;
      |        ^
Main.cpp:39:4: error: redefinition of 'long long int a [200005]'
   39 | ll a[mxN], dis[mxN], ans = LLONG_MAX;
      |    ^
Main.cpp:9:4: note: 'long long int a [200005]' previously declared here
    9 | ll a[mxN], dis[mxN], ans = LLONG_MAX;
      |    ^
Main.cpp:39:12: error: redefinition of 'long long int dis [200005]'
   39 | ll a[mxN], dis[mxN], ans = LLONG_MAX;
      |            ^~~
Main.cpp:9:12: note: 'long long int dis [200005]' previously declared here
    9 | ll a[mxN], dis[mxN], ans = LLONG_MAX;
      |            ^~~
Main.cpp:39:22: error: redefinition of 'long long int ans'
   39 | ll a[mxN], dis[mxN], ans = LLONG_MAX;
      |                      ^~~
Main.cpp:9:22: note: 'long long int ans' previously defined here
    9 | ll a[mxN], dis[mxN], ans = LLONG_MAX;
      |                      ^~~
Main.cpp:40:14: error: redefinition of 'std::vector<int> adj [200005]'
   40 | vector <int> adj[mxN];
      |              ^~~
Main.cpp:10:14: note: 'std::vector<int> adj [200005]' previously declared here
   10 | vector <int> adj[mxN];
      |              ^~~
Main.cpp:42:5: error: redefinition of 'int main()'
   42 | int main() {
      |     ^~~~
Main.cpp:12:5: note: 'int main()' previously defined here
   12 | int main() {
      |     ^~~~