Submission #482960

# Submission time Handle Problem Language Result Execution time Memory
482960 2021-10-27T05:31:44 Z jalsol Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
534 ms 72468 KB
#include "crocodile.h"

#ifdef LOCAL
#include "local.h"
#else
#include <bits/stdc++.h>
#define debug(...)
#define DB(...)
#endif

using namespace std;

const bool __initialization = []() {
    cin.tie(nullptr)->sync_with_stdio(false);
    cout << setprecision(12) << fixed;
    return true;
}();

using ll = long long;
using ld = long double;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

#define For(i, l, r) for (int i = (l); i <= (r); ++i)
#define Ford(i, r, l) for (int i = (r); i >= (l); --i)
#define Rep(i, n) For (i, 0, (n) - 1)
#define Repd(i, n) Ford (i, (n) - 1, 0)
#define Fe(...) for (auto __VA_ARGS__)

template <class C> inline int isz(const C& c) { return static_cast<int>(c.size()); }
template <class T> inline bool chmin(T& a, const T& b) { return (a > b) ? a = b, true : false; }
template <class T> inline bool chmax(T& a, const T& b) { return (a < b) ? a = b, true : false; }

constexpr ld eps = 1e-9;
constexpr int inf = 1e9;
constexpr ll linf = 1e18;

// =============================================================================

constexpr int maxn = 1e5 + 5;

struct Link { int v, c; };

struct Data {
    int u, du;
    bool operator<(const Data& o) const {
        return du > o.du;
    }
};

int n, ne, nexit;
vector<Link> g[maxn];
int esc[maxn];

int cnt[maxn];
priority_queue<Data> q;

int Dijkstra() {
    while (isz(q)) {
        auto [u, du] = q.top(); q.pop();

        if (++cnt[u] == 2) {
            if (u == 0) return du;

            Fe(&[v, c] : g[u]) {
                q.push({v, du + c});
            }
        }
    }

    return -1;
}

int travel_plan(int _N, int _M, int _R[][2], int _L[], int _K, int _P[]) {
// globalization
    n = _N; ne = _M; nexit = _K;
    Rep (i, ne) g[_R[i][0]].push_back({_R[i][1], _L[i]}), g[_R[i][1]].push_back({_R[i][0], _L[i]});
    Rep (i, nexit) esc[i] = _P[i];
// end of globalization

    Rep (i, nexit) {
        q.push({esc[i], 0});
        q.push({esc[i], 0});
    }

    return Dijkstra();
}


# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2688 KB Output is correct
5 Correct 2 ms 2764 KB Output is correct
6 Correct 2 ms 2764 KB Output is correct
7 Correct 2 ms 2764 KB Output is correct
8 Correct 2 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2688 KB Output is correct
5 Correct 2 ms 2764 KB Output is correct
6 Correct 2 ms 2764 KB Output is correct
7 Correct 2 ms 2764 KB Output is correct
8 Correct 2 ms 2764 KB Output is correct
9 Correct 3 ms 3020 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 3 ms 2764 KB Output is correct
12 Correct 8 ms 3464 KB Output is correct
13 Correct 5 ms 3532 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2688 KB Output is correct
5 Correct 2 ms 2764 KB Output is correct
6 Correct 2 ms 2764 KB Output is correct
7 Correct 2 ms 2764 KB Output is correct
8 Correct 2 ms 2764 KB Output is correct
9 Correct 3 ms 3020 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 3 ms 2764 KB Output is correct
12 Correct 8 ms 3464 KB Output is correct
13 Correct 5 ms 3532 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2764 KB Output is correct
16 Correct 534 ms 72468 KB Output is correct
17 Correct 76 ms 13252 KB Output is correct
18 Correct 82 ms 14788 KB Output is correct
19 Correct 524 ms 66860 KB Output is correct
20 Correct 289 ms 58004 KB Output is correct
21 Correct 43 ms 7552 KB Output is correct
22 Correct 471 ms 46344 KB Output is correct