Submission #90837

# Submission time Handle Problem Language Result Execution time Memory
90837 2018-12-24T17:44:26 Z Vardanyan Triumphal arch (POI13_luk) C++14
0 / 100
337 ms 17812 KB
#include<bits/stdc++.h>

using namespace std;

const int N = 300*1000+5;
int depth[N];
vector<int> g[N];
void dfs(int v,int p = 0){
    depth[v] = depth[p]+1;
    for(int i = 0;i<g[v].size();i++){
        int to = g[v][i];
        if(to == p) continue;
        dfs(to,v);
    }
}
vector<int> all;
bool check(int crew){
    if(crew == 3){
        cout<<0<<endl;
    }
    int tim = 1;
    int pos = 0;
    while(pos<all.size()){
        for(int i = 0;i<crew;i++){
            if(all[pos]<=tim) return false;
            pos++;
            if(pos>=all.size()) return true;
        }
        tim++;
    }
    return true;
}
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);
    int l = 1;
    int r = n-1;
    int ans = n-1;
    while(l<=r){
        int m = (l+r)/2;
        if(check(m)){
            ans = m;
            r = m-1;
        }
        else l = m+1;
    }*/
    int ans = g[1].size();
    for(int i = 2;i<=n;i++){
        ans = max(ans,int(g[i].size()-1));
    }
    printf("%d\n",ans);
    return 0;
}

Compilation message

luk.cpp: In function 'void dfs(int, int)':
luk.cpp:10:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<g[v].size();i++){
                   ~^~~~~~~~~~~~
luk.cpp: In function 'bool check(int)':
luk.cpp:23:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(pos<all.size()){
           ~~~^~~~~~~~~~~
luk.cpp:27:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(pos>=all.size()) return true;
                ~~~^~~~~~~~~~~~
luk.cpp: In function 'int main()':
luk.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
luk.cpp:39: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 time Memory Grader output
1 Incorrect 6 ms 7416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 7424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 7472 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 7520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 7932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 8796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 11016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 122 ms 14392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 262 ms 17796 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 337 ms 17812 KB Output isn't correct
2 Halted 0 ms 0 KB -