Submission #672157

#TimeUsernameProblemLanguageResultExecution timeMemory
672157Hacv16Crocodile's Underground City (IOI11_crocodile)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "crocodile.h" using namespace std; #define int long long int const int MAX = 2e6 + 15; const int INF = 0x3f3f3f3f; #define fr first #define sc second int dp[MAX], ans; bool ex[MAX]; vector<int> adj[MAX], w[MAX]; void calcdp(int u, int p){ if(adj[u].size() == 1){ if(ex[u]) dp[u] = 0; else dp[u] = INF; return; } dp[u] = INF; for(int i = 0; i < (int) adj[u].size(); i++){ int v = adj[u][i], c = w[u][i]; if(v == p) continue; calcdp(v, u); dp[u] = min(dp[u], dp[v] + c); } } void dfs(int u, int p){ pair<int, int> f1 = {INF, INF}, f2 = f1; for(int i = 0; i < (int) adj[u].size(); i++){ int v = adj[u][i], c = w[u][i]; if(v == p) continue; pair<int, int> cur = {dp[v] + c, v}; if(cur < f1){ swap(f1, f2); swap(cur, f1); } else if(cur < f2){ swap(f2, cur); } } ans += f2.fr; dfs(f2.sc, u); } int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]){ for(int i = 0; i < m; i++){ int u = R[i][0], v = R[i][1]; adj[u].push_back(v); adj[v].push_back(u); w[u].push_back(L[i]); w[v].push_back(L[i]); } for(int i = 0; i < k; i++) ex[P[i]] = true; calcdp(0, -1); dfs(0, -1); return ans; }

Compilation message (stderr)

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