Submission #71479

# Submission time Handle Problem Language Result Execution time Memory
71479 2018-08-24T21:18:56 Z FLDutchman Crocodile's Underground City (IOI11_crocodile) C++14
0 / 100
5 ms 868 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,l,r) for(int i = (l); i < (r); i++)
#define snd second
#define fst first
#define V vector
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

const int INF = 1e9 + 10;

struct edge{
	int v, l;
};

V<V<edge>> adj;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
	adj.resize(N);
	FOR(i, 0, M) {
		adj[R[i][0]].pb({R[i][1], L[i]});
		adj[R[i][1]].pb({R[i][0], L[i]});
	}
	priority_queue<ii, vii, greater<ii>> q;
	vi dist(N, INF);
	vi vis(N, 0);
	FOR(i,0,K) {
		//dist[P[i]] = 0;
		vis[P[i]] = 1;
		q.push({0, P[i]});
	}
	while(!q.empty()){
		ii p = q.top(); q.pop();
		int u = p.snd, d = p.fst;
		//cout << u << " " << d << " " << vis[u] << endl;
		if(!vis[u]){
			vis[u] = 1;
			continue;
		}
		assert(dist[u] == INF || dist[u] < d);
		if(dist[u] != INF) continue;
		dist[u] = d;
		if(u == 0) return d;
		for(edge e : adj[u]){
			int v = e.v, l = e.l;
			//cout<<v<<endl;
			if(dist[v] > d+l){
				//dist[v] = d+l;
				q.push({d+l, v});
			}
		}
	}
	return -1;
}


# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Runtime error 5 ms 868 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Runtime error 5 ms 868 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Runtime error 5 ms 868 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -