Submission #714482

# Submission time Handle Problem Language Result Execution time Memory
714482 2023-03-24T15:58:57 Z tcmmichaelb139 Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
555 ms 111808 KB
#include "crocodile.h"

#include "bits/stdc++.h"

using namespace std;

struct node {
    int v;
    long long time;

    bool operator<(const node &rhs) const {
        return time > rhs.time;
    }
};

int travel_plan(int n, int m, int R[][2], int L[], int k, int p[]) {
    vector<pair<int, long long>> adj[n + 1];
    for (int i = 0; i < m; i++) {
        int a = R[i][0], b = R[i][1];
        long long c = L[i];
        adj[a].push_back({b, c});
        adj[b].push_back({a, c});
    }

    vector<int> vis(n + 1, 0);

    priority_queue<node> q;
    for (int i = 0; i < k; i++) {
        q.push({p[i], 0}), vis[p[i]] = 1;
    }

    while (!q.empty()) {
        node v = q.top();
        q.pop();

        vis[v.v]++;
        if (vis[v.v] != 2) continue;

        if (v.v == 0) {
            return v.time;
        }

        for (auto u : adj[v.v]) {
            q.push({u.first, u.second + v.time});
        }
    }
    return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 448 KB Output is correct
9 Correct 2 ms 852 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 6 ms 1624 KB Output is correct
13 Correct 4 ms 1756 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 448 KB Output is correct
9 Correct 2 ms 852 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 6 ms 1624 KB Output is correct
13 Correct 4 ms 1756 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 555 ms 111808 KB Output is correct
17 Correct 82 ms 16360 KB Output is correct
18 Correct 88 ms 18980 KB Output is correct
19 Correct 529 ms 100560 KB Output is correct
20 Correct 296 ms 82296 KB Output is correct
21 Correct 41 ms 7760 KB Output is correct
22 Correct 501 ms 63176 KB Output is correct