Submission #35886

#TimeUsernameProblemLanguageResultExecution timeMemory
35886funcsrMousetrap (CEOI17_mousetrap)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #define pb push_back #define all(xs) xs.begin(), xs.end() #define rep(i, n) for (int i=0; i<(n); i++) using namespace std; int N, T, M; vector<int> G[1000000]; int dp[1000000]; bool sub[1000000]; void dfs(int x, int p) { vector<int> values; int ctr = 0, ti = -1; sub[x] = x == M; for (int t : G[x]) { if (t == p) continue; dfs(t, x); sub[x] |= sub[t]; if (sub[t]) ti = t; values.pb(dp[t]); ctr++; } if (ti != -1) { dp[x] = (ctr-1) + dp[ti]; return; } sort(all(values), greater<int>()); if (values.size() >= 2) ctr += values[1]; dp[x] = ctr; } signed main() { cin >> N >> T >> M; T--, M--; rep(i, N-1) { int u, v; cin >> u >> v; u--, v--; G[u].pb(v); G[v].pb(u); } dfs(T, -1); cout << dp[T] << "\n"; return 0; }

Compilation message (stderr)

mousetrap.cpp: In function 'void dfs(int, int)':
mousetrap.cpp:29:35: error: 'sort' was not declared in this scope
   sort(all(values), greater<int>());
                                   ^