Submission #1002312

# Submission time Handle Problem Language Result Execution time Memory
1002312 2024-06-19T12:23:35 Z 3lektra Crocodile's Underground City (IOI11_crocodile) C++14
89 / 100
359 ms 93376 KB
#include <bits/stdc++.h>
#include "crocodile.h"
#define vi vector<long long int>
#define vc vector
#define pi pair<long long int, long long int>
using namespace std;

vc<vc<pi>> edg; // Edges, aka the corridors coming out from each room
vc<pi> dis; // The two minimum distances found between 2 nodes. The fastest route will just be used to calculate the second fastest, which is the oke that will be used to obtain the other distances
int fpath = -1e9-7; // Fastest path
int u, c; // Amazing the amount of situations when a node and a cost can be useful

void dijkstra(int k, int p[]){
    priority_queue<pi> tv; // To Visit, not TeleVision or To Vandalize
    for(int i = 0; i < k; i++){
        tv.push({0,p[i]});
        dis[p[i]].first = 0;
        dis[p[i]].second = 0;
    }
    while(!tv.empty()){
        u = tv.top().second; // The node being explored right now
        c = tv.top().first; // The cost to get to u
        tv.pop();
        
        if(dis[u].second>c){continue;} // If this path is worse then why bother
        if(u == 0){
            fpath = max(fpath, c);
            continue;}
            
        for(pi p : edg[u]){     // p.first = cost, p.second = node the path leads to
            if (p.first + c > dis[p.second].second){    
                if (p.first + c > dis[p.second].first){ 
                    dis[p.second].second = dis[p.second].first;   
                    dis[p.second].first = p.first + c;} 
                    
                else{
                    dis[p.second].second = p.first + c;}
                    
                tv.push({dis[p.second].second, p.second});
            

            }
        }
    }
}



int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    edg = vc<vc<pi>>(N);
    for(int i = 0; i < M; i++){
        edg[R[i][0]].push_back({-L[i],R[i][1]});
        edg[R[i][1]].push_back({-L[i],R[i][0]});}
    
    dis = vc<pi>(N,{-1e9-7,-1e9-7});  
        
    dijkstra(K,P);

return -fpath;}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 2 ms 1112 KB Output is correct
13 Correct 2 ms 1164 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 2 ms 1112 KB Output is correct
13 Correct 2 ms 1164 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 290 ms 83636 KB Output is correct
17 Correct 59 ms 19908 KB Output is correct
18 Correct 105 ms 22388 KB Output is correct
19 Correct 359 ms 93376 KB Output is correct
20 Correct 229 ms 65876 KB Output is correct
21 Correct 35 ms 8760 KB Output is correct
22 Incorrect 215 ms 63152 KB Output isn't correct
23 Halted 0 ms 0 KB -