Submission #136908

# Submission time Handle Problem Language Result Execution time Memory
136908 2019-07-26T13:57:25 Z eohomegrownapps Crocodile's Underground City (IOI11_crocodile) C++14
46 / 100
2000 ms 632 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

vector<vector<pair<int,int> > > adjlist;
int INF = 100000000;
vector<bool> isEnd;
vector<bool> visited;
int dfs(int x){
	//cout<<x<<endl;
	visited[x]=true;
	int min1 = INF;
	int min2 = INF;
	if (isEnd[x]){
		visited[x]=false;
		return 0;
	}
	for (auto p : adjlist[x]){
		if (visited[p.second]){
			continue;
		}
		int distance = p.first+dfs(p.second);
		if (distance<min1){
			min2=min1;
			min1=distance;
		} else if (distance<min2){
			min2=distance;
		}
	}
	visited[x]=false;
	return min2;
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
	adjlist.resize(N);
	for (int i = 0; i<M; i++){
		adjlist[R[i][0]].push_back(make_pair(L[i],R[i][1]));
		adjlist[R[i][1]].push_back(make_pair(L[i],R[i][0]));
	}
	isEnd.resize(N,false);
	visited.resize(N,false);
	for (int i = 0; i<K; i++){
		isEnd[P[i]]=true;
	}
	return dfs(0);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 420 KB Output is correct
9 Execution timed out 2025 ms 632 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 420 KB Output is correct
9 Execution timed out 2025 ms 632 KB Time limit exceeded
10 Halted 0 ms 0 KB -