답안 #302658

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
302658 2020-09-19T02:37:06 Z shrek12357 악어의 지하 도시 (IOI11_crocodile) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
#include "crocodile.h"
using namespace std;

const long long INF = 1e10;
#define MAXN 15

bool ex[MAXN];
vector<pair<int, int>> adjList[MAXN];
int n, m, k;
long long dp[MAXN];

void dfs(int src, int par) {
	int cur = adjList[src].size();
	if (src != 0) {
		cur--;
	}
	if (ex[src]) {
		dp[src] = 0;
		return;
	}
	if (cur < 2) {
		return;
	}
	long long t1 = 5*INF, t2 = 5*INF;
	for (auto i : adjList[src]) {
		if (i.first == par) {
			continue;
		}
		dfs(i.first, src);
		if (dp[i.first] + i.second < t1) {
			t2 = t1;
			t1 = dp[i.first] + i.second;
		}
		else if (dp[i.first] + i.second < t2) {
			t2 = dp[i.first] + i.second;
		}
	}
	dp[src] = t2;
}

void travel_plan(int N, int M, int r[][2], int l[], int K, int p[]) {
	n = N; m = M; k = K;
	for (int i = 0; i < k; i++) {
		ex[p[i]] = true;
	}
	for (int i = 0; i < m; i++) {
		adjList[r[i][0]].push_back({ r[i][1], l[i] });
		adjList[r[i][1]].push_back({ r[i][0], l[i] });
	}
	for (int i = 0; i < n; i++) {
		dp[i] = INF;
	}
	dfs(0, 0);
	cout << dp[0] << endl;
}

Compilation message

crocodile.cpp:51:6: error: ambiguating new declaration of 'void travel_plan(int, int, int (*)[2], int*, int, int*)'
   51 | void travel_plan(int N, int M, int r[][2], int l[], int K, int p[]) {
      |      ^~~~~~~~~~~
In file included from crocodile.cpp:11:
crocodile.h:1:5: note: old declaration 'int travel_plan(int, int, int (*)[2], int*, int, int*)'
    1 | int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]);
      |     ^~~~~~~~~~~