Submission #372886

# Submission time Handle Problem Language Result Execution time Memory
372886 2021-03-02T07:46:22 Z xt0r3 Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
1066 ms 65504 KB
#include<bits/stdc++.h>
#include "crocodile.h"

using namespace std;

constexpr int MAXN = 1e5 + 5;
pair<int, int> key[MAXN];
map<pair<int, int>, bool> volt;
vector<pair<int, int> > edges[MAXN];
int n, m, k;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    n = N;
    m = M;
    k = K;
    fill(key, key + n, pair<int, int>{1e9 + 5, 1e9 + 5});

    for(int i = 0; i < m; i++){
        edges[R[i][0]].emplace_back(R[i][1], L[i]);
        edges[R[i][1]].emplace_back(R[i][0], L[i]);
    }

    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq;

    for(int i = 0; i < k; i++){
        key[P[i]].first = key[P[i]].second = 0;
        pq.push(make_pair(0, P[i]));
    }

    while(!pq.empty()){
        pair<int, int> p = pq.top();
        pq.pop();

        int u = p.second;
        int w = p.first;

        if(key[u].second != w)
            continue;

        for(pair<int, int> q : edges[u]){

            int curr = w + q.second;
            int v = q.first;

            if(key[v].second > curr && !volt[make_pair(min(u, v), max(u, v))]){

                volt[make_pair(min(u, v), max(u, v))] = 1;

                if(key[v].first > curr)
                    swap(curr, key[v].first);

                key[v].second = curr;

                pq.push(make_pair(key[v].second, v));
            }
        }

    }
  return key[0].second;
}


# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 3 ms 2668 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 3 ms 2796 KB Output is correct
6 Correct 2 ms 2796 KB Output is correct
7 Correct 3 ms 2924 KB Output is correct
8 Correct 3 ms 2796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 3 ms 2668 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 3 ms 2796 KB Output is correct
6 Correct 2 ms 2796 KB Output is correct
7 Correct 3 ms 2924 KB Output is correct
8 Correct 3 ms 2796 KB Output is correct
9 Correct 4 ms 2924 KB Output is correct
10 Correct 2 ms 2668 KB Output is correct
11 Correct 3 ms 2796 KB Output is correct
12 Correct 6 ms 3052 KB Output is correct
13 Correct 6 ms 3180 KB Output is correct
14 Correct 2 ms 2796 KB Output is correct
15 Correct 3 ms 2796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 3 ms 2668 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 3 ms 2796 KB Output is correct
6 Correct 2 ms 2796 KB Output is correct
7 Correct 3 ms 2924 KB Output is correct
8 Correct 3 ms 2796 KB Output is correct
9 Correct 4 ms 2924 KB Output is correct
10 Correct 2 ms 2668 KB Output is correct
11 Correct 3 ms 2796 KB Output is correct
12 Correct 6 ms 3052 KB Output is correct
13 Correct 6 ms 3180 KB Output is correct
14 Correct 2 ms 2796 KB Output is correct
15 Correct 3 ms 2796 KB Output is correct
16 Correct 650 ms 51068 KB Output is correct
17 Correct 189 ms 23760 KB Output is correct
18 Correct 251 ms 25312 KB Output is correct
19 Correct 1066 ms 65504 KB Output is correct
20 Correct 299 ms 36524 KB Output is correct
21 Correct 69 ms 10984 KB Output is correct
22 Correct 408 ms 43496 KB Output is correct