Submission #1103365

# Submission time Handle Problem Language Result Execution time Memory
1103365 2024-10-20T17:20:43 Z Ahmed57 Tree (IOI24_tree) C++17
0 / 100
50 ms 8356 KB
#include <bits/stdc++.h>
using namespace std;
long long cnt = 0;
void init(std::vector<int> P, std::vector<int> W){
    int deg[P.size()] = {0};
    int root = -1;
    for(int i = 0;i<P.size();i++){
        int x = P[i];
        if(x==-1){
            root = x;
        }else{
            deg[x]++;
            deg[i]++;
        }
    }
    for(int i = 0;i<P.size();i++){
        if(i==root)continue;
        if(deg[i]==1)cnt++;
    }
}
long long query(int L, int R){
    return cnt*L+max(0ll,(cnt*L-R));
}

Compilation message

tree.cpp: In function 'void init(std::vector<int>, std::vector<int>)':
tree.cpp:7:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for(int i = 0;i<P.size();i++){
      |                   ~^~~~~~~~~
tree.cpp:16:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i = 0;i<P.size();i++){
      |                   ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 6848 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 50 ms 8276 KB Output is correct
2 Incorrect 46 ms 8356 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 50 ms 8276 KB Output is correct
2 Incorrect 46 ms 8356 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 6996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 32 ms 6848 KB Output isn't correct
3 Halted 0 ms 0 KB -