Submission #106244

# Submission time Handle Problem Language Result Execution time Memory
106244 2019-04-17T16:05:14 Z tincamatei Crocodile's Underground City (IOI11_crocodile) C++14
46 / 100
7 ms 2944 KB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 100000;
const int INF = 1000000001;

vector<pair<int, int> > graph[MAX_N];
int dp[MAX_N];
bool proc[MAX_N];

void dfs(int nod) {
	if(!proc[nod]) {
		int best[2];
		proc[nod] = true;
		
		dp[nod] = INF;
		best[0] = best[1] = INF;

		for(auto it: graph[nod]) {
			dfs(it.first);
			int cost = dp[it.first] + it.second;
			if(cost <= best[0]) {
				best[1] = best[0];
				best[0] = cost;
			} else if(cost <= best[1])
				best[1] = cost;
		}

		dp[nod] = best[1];
	}
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
  for(int i = 0; i < M; ++i) {
		graph[R[i][0]].push_back(make_pair(R[i][1], L[i]));
		graph[R[i][1]].push_back(make_pair(R[i][0], L[i]));
	}
	
	for(int i = 0; i < N; ++i)
		dp[i] = INF;
	for(int i = 0; i < K; ++i) {
		dp[P[i]] = 0;
		proc[P[i]] = true;
	}
	
	dfs(0);

	return dp[0];
}

# Verdict Execution time Memory Grader output
1 Correct 5 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 4 ms 2816 KB Output is correct
5 Correct 4 ms 2688 KB Output is correct
6 Correct 6 ms 2816 KB Output is correct
7 Correct 6 ms 2816 KB Output is correct
8 Correct 5 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 4 ms 2816 KB Output is correct
5 Correct 4 ms 2688 KB Output is correct
6 Correct 6 ms 2816 KB Output is correct
7 Correct 6 ms 2816 KB Output is correct
8 Correct 5 ms 2816 KB Output is correct
9 Correct 7 ms 2944 KB Output is correct
10 Incorrect 4 ms 2688 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 4 ms 2816 KB Output is correct
5 Correct 4 ms 2688 KB Output is correct
6 Correct 6 ms 2816 KB Output is correct
7 Correct 6 ms 2816 KB Output is correct
8 Correct 5 ms 2816 KB Output is correct
9 Correct 7 ms 2944 KB Output is correct
10 Incorrect 4 ms 2688 KB Output isn't correct
11 Halted 0 ms 0 KB -