Submission #219766

# Submission time Handle Problem Language Result Execution time Memory
219766 2020-04-06T09:58:12 Z Andrei_Cotor Crocodile's Underground City (IOI11_crocodile) C++11
89 / 100
662 ms 61320 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]=1000000000;

    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!=1000000000)
                {
                    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 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2816 KB Output is correct
5 Correct 7 ms 2688 KB Output is correct
6 Correct 6 ms 2688 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 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2816 KB Output is correct
5 Correct 7 ms 2688 KB Output is correct
6 Correct 6 ms 2688 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 9 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 7 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 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2816 KB Output is correct
5 Correct 7 ms 2688 KB Output is correct
6 Correct 6 ms 2688 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 9 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 7 ms 2816 KB Output is correct
16 Correct 528 ms 57204 KB Output is correct
17 Correct 88 ms 13816 KB Output is correct
18 Correct 111 ms 15224 KB Output is correct
19 Correct 662 ms 61320 KB Output is correct
20 Correct 332 ms 49656 KB Output is correct
21 Correct 45 ms 7672 KB Output is correct
22 Incorrect 350 ms 46200 KB Output isn't correct