Submission #582710

# Submission time Handle Problem Language Result Execution time Memory
582710 2022-06-24T10:25:24 Z stevancv Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
512 ms 64496 KB
#include <bits/stdc++.h>
#include "crocodile.h"
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) {
    vector<vector<pair<int, int>>> g(n);
    for (int i = 0; i < m; i++) {
        g[r[i][0]].push_back({r[i][1], l[i]});
        g[r[i][1]].push_back({r[i][0], l[i]});
    }
    vector<int> was(n);
    vector<ll> da(n, 1e18), db(n, 1e18);
    priority_queue<pair<ll, pair<int, int>>> pq;
    for (int i = 0; i < k; i++) {
        was[p[i]] = 1;
        da[p[i]] = db[p[i]] = 0;
        pq.push({0, {p[i], -1}});
    }
    while (!pq.empty()) {
        auto xyz = pq.top();
        pq.pop();
        ll x = -xyz.first;
        int y = xyz.second.first;
        int z = xyz.second.second;
        was[y]++;
        if (was[y] != 2) continue;
        for (auto u : g[y]) {
            if (u.first == z) continue;
            ll di = x + u.second;
            if (da[u.first] > di) {
                db[u.first] = da[u.first];
                da[u.first] = di;
                pq.push({-di, {u.first, y}});
            }
            else if (db[u.first] > di) {
                db[u.first] = di;
                pq.push({-di, {u.first, y}});
            }
        }
    }
    return db[0];
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 340 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 3 ms 832 KB Output is correct
13 Correct 3 ms 852 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 340 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 3 ms 832 KB Output is correct
13 Correct 3 ms 852 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 385 ms 59520 KB Output is correct
17 Correct 67 ms 14796 KB Output is correct
18 Correct 95 ms 16412 KB Output is correct
19 Correct 512 ms 64496 KB Output is correct
20 Correct 240 ms 47252 KB Output is correct
21 Correct 39 ms 6280 KB Output is correct
22 Correct 260 ms 44724 KB Output is correct