Submission #31794

# Submission time Handle Problem Language Result Execution time Memory
31794 2017-09-09T04:54:49 Z top34051 Burza (COCI16_burza) C++14
0 / 160
0 ms 2024 KB
#include<bits/stdc++.h>
using namespace std;
#define maxn 405
int n,k;
int dp[maxn], mx[2];
vector<int> from[maxn];
void upd(int val) {
    int i;
    for(i=0;i<2;i++) if(mx[i]<val) swap(mx[i],val);
}
void dfs(int x,int last) {
    int i;
    for(i=0;i<from[x].size();i++) if(from[x][i]!=last) dfs(from[x][i],x);
    mx[0] = mx[1] = -1;
    for(i=0;i<from[x].size();i++) if(from[x][i]!=last) upd(dp[from[x][i]]);
    for(i=0;i<2;i++) if(mx[i]!=-1) dp[x] = mx[i] + 1;
}
main() {
    int i,x,y;
    scanf("%d%d",&n,&k);
    for(i=0;i<n-1;i++) {
        scanf("%d%d",&x,&y);
        from[x].push_back(y); from[y].push_back(x);
    }
    dfs(1,0);
  	printf("NE");
}

Compilation message

burza.cpp: In function 'void dfs(int, int)':
burza.cpp:13:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0;i<from[x].size();i++) if(from[x][i]!=last) dfs(from[x][i],x);
              ^
burza.cpp:15:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0;i<from[x].size();i++) if(from[x][i]!=last) upd(dp[from[x][i]]);
              ^
burza.cpp: At global scope:
burza.cpp:18:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
burza.cpp: In function 'int main()':
burza.cpp:20:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
                        ^
burza.cpp:22:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&x,&y);
                            ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Incorrect 0 ms 2024 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Incorrect 0 ms 2024 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Incorrect 0 ms 2024 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Incorrect 0 ms 2024 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Incorrect 0 ms 2024 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Incorrect 0 ms 2024 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Incorrect 0 ms 2024 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Incorrect 0 ms 2024 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Incorrect 0 ms 2024 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Incorrect 0 ms 2024 KB Output isn't correct
4 Halted 0 ms 0 KB -