Submission #1068228

# Submission time Handle Problem Language Result Execution time Memory
1068228 2024-08-21T08:43:41 Z apper Race (IOI11_race) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long 
#define pb push_back
using namespace std;
using namespace __gnu_pbds;
/*------------------------------------code------------------------------------*/
const ll MAXN=1e5+9;
const ll INF=1e9+9;
const ll R=(1<<18);
const int X=18;
//const ll M=1e9+7;
//const ll P=47;

int n, k;
vector<pair<int, int>> adj[MAXN];
vector<pair<int, int>> edges;
int ans=INF;

void dfs(int v, int p, ll d, int cnt)
{
	if(d==k)
	{
		ans=min(ans, cnt);
		return;
	}
	for(auto [u, w] : adj[v])
	{
		if(u==p || d+w>k || cnt+1>ans)
			continue;
		dfs(u, v, d+w, cnt+1);
	}
}

void solve()
{
	for(int i=1;i<=n;i++)
		dfs(i, -1, 0, 0);
	cout<<(ans==INF ? -1 : ans);
}

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(0);
	cin>>n>>k;
	for(int i=0,a,b;i<n-1;i++)
	{
		cin>>a>>b;
		edges.pb(make_pair(a, b));
	}
	for(int i=0,w;i<n-1;i++)
	{
		cin>>w;
		auto [a, b] = edges[i];
		adj[a].pb({b, w});
		adj[b].pb({a, w});
	}
	edges.clear();
	solve();
	return 0;
}

Compilation message

/usr/bin/ld: /tmp/cciRDQAZ.o: in function `main':
race.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccdFWKR0.o:grader.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccdFWKR0.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