Submission #541512

#TimeUsernameProblemLanguageResultExecution timeMemory
541512adespawnMousetrap (CEOI17_mousetrap)C++14
25 / 100
776 ms69516 KiB
#include <bits/stdc++.h> using namespace std; vector<int> sc[1000006]; long long solve(int w, int f) { priority_queue<int> k; for (auto i : sc[w]) { if (i == f) continue; k.push(solve(i, w)); } while (k.size() < 2) k.push(0); k.pop(); return sc[w].size() - 1 + k.top(); } int main() { ios_base::sync_with_stdio(0); int n, m, k; cin >> n >> m >> k; for (int i = 1; i < n; i++) { int a, b; cin >> a >> b; sc[a].push_back(b); sc[b].push_back(a); } cout << solve(k, m); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...