Submission #598402

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

const int INF = 1e9+5;

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
// return -1;
 vector<pair<int, int> > adj[n];
 for(int i=0; i<m; ++i){
  adj[r[i][1]].push_back({r[i][0], l[i]});
  adj[r[i][0]].push_back({r[i][1], l[i]});
 }
 vector<pair<int, int> > d(n, {INF, INF});
 vector<bool> vis(n, 0);
 priority_queue<pair<int, int> > pq;
 for(int i=0; i<k; ++i){
  d[p[i]]. f = d[p[i]].s =  0;
  pq.push({0, p[i]});
 }
 while(!pq.empty()){
 /*for(int i=0; i<n; ++i)
  cout << d[i].f << " " << d[i].s << endl;
 cout << endl;*/
  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].s + w < d[u].f){
    d[u].s = d[u].f;
    d[u].f = d[s].s + w;
    pq.push({-d[u].f, u});
   } else if(d[s].s + w == d[u].f)
    d[u].s = d[u].f;
   else if(d[s].s + w < d[u].s)
    d[u].s = d[s].s + w;
  }
 }
 //cout << d[0].s << endl;
 if(d[0].s == INF) return -1;
 return d[0].s;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -