# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
249380 | 2020-07-14T19:18:23 Z | Sorting | Mousetrap (CEOI17_mousetrap) | C++14 | 785 ms | 77340 KB |
#include <bits/stdc++.h> using namespace std; const int k_N = 1e6 + 3; int n, t, m; vector<int> adj[k_N]; pair<int, bool> dp[k_N]; int solve(int node, int p){ auto &[ans, solved] = dp[node]; if(solved) return ans; solved = true; ans = adj[node].size() - 1; int max1 = 0, max2 = 0; for(int to: adj[node]){ if(to == p) continue; int curr = solve(to, node); if(curr >= max1){ max2 = max1; max1 = curr; } else if(curr >= max2) max2 = curr; } ans += max2; //cout << ans << " - " << node << " ans node\n"; return ans; } int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> t >> m; for(int i = 0; i < n - 1; ++i){ int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } cout << solve(m, t) << "\n"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 14 ms | 23808 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 386 ms | 62968 KB | Output is correct |
2 | Correct | 351 ms | 71032 KB | Output is correct |
3 | Correct | 785 ms | 77304 KB | Output is correct |
4 | Correct | 368 ms | 50424 KB | Output is correct |
5 | Correct | 778 ms | 77304 KB | Output is correct |
6 | Correct | 782 ms | 77340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 14 ms | 23808 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 14 ms | 23808 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |