# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
90839 | Vardanyan | Triumphal arch (POI13_luk) | C++14 | 249 ms | 17616 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int N = 300*1000+5;
int depth[N];
vector<int> g[N];
int mark[N];
bool F = true;
int dp[N];
int ans = 0;
void dfs(int v,int p = -1){
int x = g[v].size();
if(p!=-1) x--;
for(int i = 0;i<g[v].size();i++){
int to = g[v][i];
dp[to] = max(dp[to],dp[v]);
dp[to] = max(dp[to],x);
ans = max(ans,dp[to]);
}
}
int main()
{
int n;
scanf("%d",&n);
for(int i = 1;i<=n-1;i++){
int x,y;
scanf("%d%d",&x,&y);
g[x].push_back(y);
g[y].push_back(x);
}
if(n == 1){
printf("0\n");
return 0;
}
dfs(1);
cout<<ans<<endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |