Submission #989700

# Submission time Handle Problem Language Result Execution time Memory
989700 2024-05-28T15:15:00 Z vjudge2 Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
421 ms 60692 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pii pair<int, int>
 
const ll INF = 1e18;
 
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
    vector<vector<pii>> adj(N);
    for (int i = 0; i < M; i++) {
        adj[R[i][0]].push_back({R[i][1], L[i]});
        adj[R[i][1]].push_back({R[i][0], L[i]});
    }
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<>> q;
    vector<int> cnt(N, 0);
    vector<ll> di(N, INF);
    for (int i = 0; i < K; i++) {
        cnt[P[i]] = 1, di[P[i]] = 0;
        q.push({0, P[i]});
    }
    while (!q.empty()) {
        auto [dist, u] = q.top();
        q.pop();
        cnt[u]++;
        if (cnt[u] == 2) di[u] = dist;
        if (cnt[u] != 2 || di[u] != dist) continue;
        for (auto& [v, w] : adj[u]) {
            if (cnt[v] < 2 && di[v] > di[u] + w) {
                q.push({di[u] + w, v});
            }
        }
    }
    return di[0];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 2 ms 4700 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 4 ms 5080 KB Output is correct
13 Correct 3 ms 5208 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 2 ms 4700 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 4 ms 5080 KB Output is correct
13 Correct 3 ms 5208 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 396 ms 57632 KB Output is correct
17 Correct 45 ms 12624 KB Output is correct
18 Correct 64 ms 13744 KB Output is correct
19 Correct 421 ms 60692 KB Output is correct
20 Correct 288 ms 52920 KB Output is correct
21 Correct 32 ms 7760 KB Output is correct
22 Correct 281 ms 32716 KB Output is correct