Submission #1096133

# Submission time Handle Problem Language Result Execution time Memory
1096133 2024-10-03T21:20:11 Z I_FloPPed21 Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
305 ms 117608 KB
#include <bits/stdc++.h>
using namespace std;
const int N=2e6+1;
const long long inf=1e18;
struct nod
{
    int unde;
    long long cost;
};

struct coada
{
    int unde;
    long long cost;
};

struct compare
{
    bool operator()(coada &x,coada &y)
    {
        return x.cost>y.cost;
    }
};
vector<nod>adj[N];
long long best[N][2];
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++)
    {
        best[i][0]=best[i][1]=inf;
    }
    priority_queue<coada,vector<coada>,compare>pq;
    for(int i=0; i<k; i++)
    {
        best[p[i]][0]=0;
        best[p[i]][1]=0;
        pq.push({p[i],0});
    }
    while(!pq.empty())
    {
        int nod=pq.top().unde;
        long long cost=pq.top().cost;
        pq.pop();
        if(cost!=best[nod][1])
            continue;
        for(auto u:adj[nod])
        {
            if(best[u.unde][0]>cost+u.cost)
            {

                if(best[u.unde][1]!=best[u.unde][0])
                {
                    best[u.unde][1]=best[u.unde][0];
                    if(best[u.unde][1]!=inf)
                        pq.push({u.unde,best[u.unde][1]});
                }
                best[u.unde][0]=cost+u.cost;

            }
            else if(best[u.unde][1]>cost+u.cost)
            {
                best[u.unde][1]=cost+u.cost;
                pq.push({u.unde,best[u.unde][1]});
            }
        }
    }
    return best[0][1];
}

# Verdict Execution time Memory Grader output
1 Correct 19 ms 47196 KB Output is correct
2 Correct 19 ms 47196 KB Output is correct
3 Correct 19 ms 47452 KB Output is correct
4 Correct 24 ms 47384 KB Output is correct
5 Correct 20 ms 47452 KB Output is correct
6 Correct 19 ms 47284 KB Output is correct
7 Correct 19 ms 47532 KB Output is correct
8 Correct 19 ms 47452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 47196 KB Output is correct
2 Correct 19 ms 47196 KB Output is correct
3 Correct 19 ms 47452 KB Output is correct
4 Correct 24 ms 47384 KB Output is correct
5 Correct 20 ms 47452 KB Output is correct
6 Correct 19 ms 47284 KB Output is correct
7 Correct 19 ms 47532 KB Output is correct
8 Correct 19 ms 47452 KB Output is correct
9 Correct 19 ms 47592 KB Output is correct
10 Correct 19 ms 47192 KB Output is correct
11 Correct 19 ms 47372 KB Output is correct
12 Correct 21 ms 47808 KB Output is correct
13 Correct 21 ms 47964 KB Output is correct
14 Correct 19 ms 47448 KB Output is correct
15 Correct 19 ms 47452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 47196 KB Output is correct
2 Correct 19 ms 47196 KB Output is correct
3 Correct 19 ms 47452 KB Output is correct
4 Correct 24 ms 47384 KB Output is correct
5 Correct 20 ms 47452 KB Output is correct
6 Correct 19 ms 47284 KB Output is correct
7 Correct 19 ms 47532 KB Output is correct
8 Correct 19 ms 47452 KB Output is correct
9 Correct 19 ms 47592 KB Output is correct
10 Correct 19 ms 47192 KB Output is correct
11 Correct 19 ms 47372 KB Output is correct
12 Correct 21 ms 47808 KB Output is correct
13 Correct 21 ms 47964 KB Output is correct
14 Correct 19 ms 47448 KB Output is correct
15 Correct 19 ms 47452 KB Output is correct
16 Correct 260 ms 111588 KB Output is correct
17 Correct 69 ms 58964 KB Output is correct
18 Correct 69 ms 61268 KB Output is correct
19 Correct 305 ms 117608 KB Output is correct
20 Correct 183 ms 99796 KB Output is correct
21 Correct 39 ms 53072 KB Output is correct
22 Correct 198 ms 94488 KB Output is correct