Submission #229371

# Submission time Handle Problem Language Result Execution time Memory
229371 2020-05-04T10:38:36 Z kshitij_sodani Crocodile's Underground City (IOI11_crocodile) C++17
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define a first
#define b second
#define pb push_back
#include <crocodile.h>
llo mod=100000007;
int travel_plan(int n,int m,int r[][2],int l[],int k,int p[]){
	int vis[n];
	for(int i=0;i<n;i++){
		vis[i]=0;
	}
	for(int i=0;i<k;i++){
		vis[p[i]]=1;
	}
	vector<pair<int,int>> adj[n];
	for(int i=0;i<m;i++){
		adj[r[i][0]].pb({r[i][1],l[i]});
		adj[r[i][1]].pb({r[i][0],l[i]});
	}
	int dist[n];
	int dist2[n];
	for(int i=0;i<n;i++){
		dist[i]=-1;
		dist2[i]=-1;
	}
	priority_queue<pair<int,int>> ac;
	for(int i=0;i<n;i++){
		if(vis[i]==1){
			dist[i]=0;
			dist2[i]=0;
			ac.push({0,i});
		}	
	}
 
	while(ac.size()){
		pair<int,int> no=ac.top();
		ac.pop();
		no.a=-no.a;
		for(auto j:adj[no.b]){
			int co=dist2[j.a]+j.b;
			if(co>=mod){
				continue;
			}
			if(dist[j.a]==-1 or dist[j.a]>=co){
				dist2[j.a]=dist[j.a];
				dist[j.a]=co;
				if(dist2[j.a]!=-1){
					ac.push({-dist2[j.a],j.a});
				}
			}
			else if(dist2[j.a]==-1 or dist2[j.a]>co){
				dist2[j.a]=co;
				ac.push({-dist2[j.a],j.a});
			}
		}
	}
	if(dist2[0]==-1){
		while(true){
			continue;
		}
	}
	return dist2[0];
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -