Submission #219768

# Submission time Handle Problem Language Result Execution time Memory
219768 2020-04-06T10:00:01 Z Andrei_Cotor Crocodile's Underground City (IOI11_crocodile) C++11
89 / 100
631 ms 45040 KB
#include"crocodile.h"
#include<vector>
#include<queue>

using namespace std;

vector<pair<int,int> > Adj[100005];
int Dist[2][100005];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    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]});
    }

    for(int i=0; i<N; i++)
        Dist[0][i]=Dist[1][i]=1000000001;

    priority_queue<pair<int,int> > Q;
    for(int i=0; i<K; i++)
    {
        Dist[0][P[i]]=Dist[1][P[i]]=0;
        Q.push({0,P[i]});
    }

    while(!Q.empty())
    {
        int cost=-Q.top().first;
        int nod=Q.top().second;
        Q.pop();

        if(cost!=Dist[1][nod])
            continue;

        for(auto other:Adj[nod])
        {
            int newCost=cost+other.second;
            if(newCost<Dist[0][other.first])
            {
                int aux=Dist[0][other.first];
                Dist[0][other.first]=newCost;

                if(aux!=1000000001)
                {
                    Dist[1][other.first]=aux;
                    Q.push({-aux,other.first});
                }
            }
            else if(newCost<Dist[1][other.first])
            {
                Dist[1][other.first]=newCost;
                Q.push({-newCost,other.first});
            }
        }
    }

    return Dist[1][0];
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2736 KB Output is correct
3 Correct 7 ms 2688 KB Output is correct
4 Correct 7 ms 2816 KB Output is correct
5 Correct 6 ms 2816 KB Output is correct
6 Correct 6 ms 2816 KB Output is correct
7 Correct 6 ms 2816 KB Output is correct
8 Correct 6 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2736 KB Output is correct
3 Correct 7 ms 2688 KB Output is correct
4 Correct 7 ms 2816 KB Output is correct
5 Correct 6 ms 2816 KB Output is correct
6 Correct 6 ms 2816 KB Output is correct
7 Correct 6 ms 2816 KB Output is correct
8 Correct 6 ms 2816 KB Output is correct
9 Correct 8 ms 2944 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 7 ms 2816 KB Output is correct
12 Correct 13 ms 3200 KB Output is correct
13 Correct 9 ms 3200 KB Output is correct
14 Correct 6 ms 2688 KB Output is correct
15 Correct 8 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2736 KB Output is correct
3 Correct 7 ms 2688 KB Output is correct
4 Correct 7 ms 2816 KB Output is correct
5 Correct 6 ms 2816 KB Output is correct
6 Correct 6 ms 2816 KB Output is correct
7 Correct 6 ms 2816 KB Output is correct
8 Correct 6 ms 2816 KB Output is correct
9 Correct 8 ms 2944 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 7 ms 2816 KB Output is correct
12 Correct 13 ms 3200 KB Output is correct
13 Correct 9 ms 3200 KB Output is correct
14 Correct 6 ms 2688 KB Output is correct
15 Correct 8 ms 2816 KB Output is correct
16 Correct 511 ms 41072 KB Output is correct
17 Correct 87 ms 10744 KB Output is correct
18 Correct 117 ms 12092 KB Output is correct
19 Correct 631 ms 45040 KB Output is correct
20 Correct 335 ms 36856 KB Output is correct
21 Correct 45 ms 6520 KB Output is correct
22 Incorrect 345 ms 31864 KB Output isn't correct