Submission #492925

# Submission time Handle Problem Language Result Execution time Memory
492925 2021-12-09T18:38:18 Z Newtech66 Crocodile's Underground City (IOI11_crocodile) C++17
89 / 100
558 ms 77180 KB
#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
using lol=long long int;
const lol inf=1e18+8;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    vector<vector<pair<int,lol> > > 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]});
    }
    priority_queue<pair<lol,int>,vector<pair<lol,int> >,greater<pair<lol,int> > > pq;
    vector<lol> mn(N,inf);
    vector<lol> smn(N,inf);
    for(int i=0;i<K;i++)
    {
        pq.push({0,P[i]});
        mn[P[i]]=smn[P[i]]=0;
    }
    while(!pq.empty())
    {
        auto [dist,u]=pq.top();
        pq.pop();
        if(dist>smn[u]) continue;
        for(auto [v,w]:g[u])
        {
            lol nxt=min(inf,w+dist);
            if(nxt<=mn[v])
            {
                smn[v]=min(inf,mn[v]);
                mn[v]=min(inf,nxt);
                pq.push({smn[v],v});
            }else if(nxt<smn[v])
            {
                smn[v]=min(inf,nxt);
                pq.push({smn[v],v});
            }
        }
    }
    return smn[0];
}


# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 3 ms 844 KB Output is correct
13 Correct 3 ms 972 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 3 ms 844 KB Output is correct
13 Correct 3 ms 972 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 425 ms 67452 KB Output is correct
17 Correct 87 ms 16576 KB Output is correct
18 Correct 110 ms 18756 KB Output is correct
19 Correct 558 ms 77180 KB Output is correct
20 Correct 264 ms 52688 KB Output is correct
21 Correct 41 ms 7300 KB Output is correct
22 Incorrect 303 ms 48740 KB Output isn't correct