Submission #598387

# Submission time Handle Problem Language Result Execution time Memory
598387 2022-07-18T08:28:05 Z daria Crocodile's Underground City (IOI11_crocodile) C++14
0 / 100
1 ms 212 KB
#include "crocodile.h"
#include "bits/stdc++.h"
using namespace std;
#define f first
#define s second

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
 vector<pair<int, int> > adj[n];
 for(int i=0; i<m; ++i)
  adj[r[i][1]].push_back({r[i][0], l[i]});

 vector<pair<int, int> > d(n, {1e9+5, 1e9+5});
 vector<bool> vis(n, 0);
 priority_queue<pair<int, int> > pq;
 for(int i=0; i<k; ++i){
  d[p[i]].f = 0;
  pq.push({0, p[i]});
 }
 while(!pq.empty()){
  int s = pq.top().s; pq.pop();
  if(vis[s]) continue;
  vis[s] = 1;
  for(auto p : adj[s]){
   int u = p.f, w = p.s;
   if(d[s].f + w < d[u].f){
    d[u].f = d[s].f + w;
    pq.push({-d[u].f, u});
   } else if(d[s].f + w < d[u].s)
    d[u].s = d[s].f + w;
  }
 }
 if(d[0].s == 1e9+5) return -1;
 return d[0].s;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -