Submission #1093662

# Submission time Handle Problem Language Result Execution time Memory
1093662 2024-09-27T08:00:16 Z Aviansh Crocodile's Underground City (IOI11_crocodile) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#include "crocodile.h"

using namespace std;

int travel_plan(int n, int m, int edges[][2], int w[], int k, int p[])
{
    vector<pair<int,int>> g[n];
    for(int i =0;i<m;i++){
        g[edges[i][0]].push_back({edges[i][1],w[i]});
        g[edges[i][1]].push_back({edges[i][0],w[i]});
    }
    bool ex[n];
    fill(ex,ex+n,0);
    for(int i = 0;i<k;i++){
        ex[p[i]]=1;
    }
    bool vis[n];
    fill(vis,vis+n,0);
    vis[0]=1;
    bool rem[n+1];
    fill(rem,rem+n+1,0);
    priority_queue<array<int,3>,vector<array<int,3>>,greater<array<int,3>>>pq; // dist,origin,destination
    pq.push({0,n,0});
    while(!pq.empty()){
        array<int,3> a = pq.top();
        pq.pop();
        //cout << "popped: " << a[0] << " " << a[1] << " " << a[2] << "\n";
        if(ex[a[2]]){
            if(rem[a[1]]){
                return a[0];
            }
            else{
                rem[a[1]]=1;
                continue;
            }
        }
        vis[a[2]]=1;
        for(pair<int,int>p:g[a[2]]){
            if(vis[p.first])
                continue;
            //cout << "adding to pq: " << a[0]+p.second << " " << a[2] << " " << p.first << "\n";
            pq.push({a[0]+p.second,a[2],p.first});
        }
    }
    assert(0);
    return -1;
}


# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -