Submission #371604

#TimeUsernameProblemLanguageResultExecution timeMemory
371604evnTriumphal arch (POI13_luk)C++14
0 / 100
285 ms22440 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second #define pb push_back #define mp make_pair #define sz(a) a.size() typedef long long ll; typedef pair<int, int> pii; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; int N; vector<int> adj[300005]; int dp[300005]; void dfs(int u, int p){ int child = 0; for(int v : adj[u]){ if(v!=p){ child++; dfs(v, u); } } dp[u] = child; for(int v : adj[u]){ if(v != p){ dp[u] = max(dp[u], dp[v]); } } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> N; for(int i = 0; i < N-1;i ++){ int a, b; cin >> a >> b; a--; b--; adj[a].pb(b); adj[b].pb(a); } dfs(0, -1); cout << dp[0] << '\n'; }
#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...