Submission #90839

#TimeUsernameProblemLanguageResultExecution timeMemory
90839VardanyanTriumphal arch (POI13_luk)C++14
0 / 100
249 ms17616 KiB
#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)

luk.cpp: In function 'void dfs(int, int)':
luk.cpp:15:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<g[v].size();i++){
                   ~^~~~~~~~~~~~
luk.cpp: In function 'int main()':
luk.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
luk.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&x,&y);
         ~~~~~^~~~~~~~~~~~~~
#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...