Submission #674238

#TimeUsernameProblemLanguageResultExecution timeMemory
674238mdubRace (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;

struct Edge {
	int to; int weight;
};

int n; int k;
vector<vector<Edge>> g;
vector<bool> seen;
map<int, stack<int>> mp;
vector<int> weights;
int ans;
void dfs(int iNode, int sum, int stage) {
	seen[iNode] = true;
	mp[sum].push(stage);
	if (!mp[sum- k].empty())
	    ans = min(ans, stage - mp[sum- k].top());

	for (auto adj: g[iNode]) {
		if (!seen[adj.to]) {
			dfs(adj.to, sum+adj.weight, stage + 1);
		}
	}
	mp[sum].pop();
	
			
}	

int best_path(int n2, int k2, vector<vector<int>> h, vector<int> l) {
    n = n2; k = k2;
	g.resize(n);
	seen.assign(n, 0);
	ans = 1e9;
	for (int i = 0; i < n - 1; i++) {
		int n1 = h[i][0], n2 = h[i][1];
		g[n1].push_back({n2, l[i]});
		g[n2].push_back({n1, l[i]});
	}

	dfs(0, 0, 0);
	return ans;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/cckSyDsS.o: in function `main':
grader.cpp:(.text.startup+0x28): undefined reference to `best_path(int, int, int (*) [2], int*)'
collect2: error: ld returned 1 exit status