답안 #106246

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
106246 2019-04-17T16:11:35 Z tincamatei 악어의 지하 도시 (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] && dp[nod] == INF) {
		int best[2];
		proc[nod] = true;
		
		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];
		proc[nod] = false;
	}
}

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];
}

# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 0 ms 2688 KB Output is correct
4 Correct 5 ms 2688 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 5 ms 2816 KB Output is correct
7 Correct 5 ms 2816 KB Output is correct
8 Correct 5 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 0 ms 2688 KB Output is correct
4 Correct 5 ms 2688 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 5 ms 2816 KB Output is correct
7 Correct 5 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 Correct 4 ms 2688 KB Output is correct
11 Incorrect 6 ms 2816 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 0 ms 2688 KB Output is correct
4 Correct 5 ms 2688 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 5 ms 2816 KB Output is correct
7 Correct 5 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 Correct 4 ms 2688 KB Output is correct
11 Incorrect 6 ms 2816 KB Output isn't correct
12 Halted 0 ms 0 KB -