제출 #1013889

#제출 시각아이디문제언어결과실행 시간메모리
1013889basa새로운 문제 (POI13_luk)C++14
0 / 100
83 ms19280 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int maxn = 300005; int mx = 0; vector<int>adj[maxn]; void dfs(int v, int p, int dpth){ // cout << v << ' ' << mx << ' ' << adj[v].size() - 1 << ' ' << mx - dpth << '\n'; mx += max(0ll, (int)(adj[v].size() - (p != -1 ? 1 : 0) - max(mx - dpth, 0ll) - dpth)); for(int i : adj[v]){ if(i == p) continue; dfs(i, v, dpth + 1); } } signed main() { cin.tie(0) -> sync_with_stdio(0); int n; cin >> n; 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 << '\n'; dfs(1, -1, 0); cout << mx; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...