Submission #1103658

# Submission time Handle Problem Language Result Execution time Memory
1103658 2024-10-21T13:28:55 Z Ahmed57 Tree (IOI24_tree) C++17
7 / 100
57 ms 8488 KB
#include <bits/stdc++.h>
using namespace std;
long long cnt = 0;
bool nah = 0;
void init(std::vector<int> P, std::vector<int> W){
    int deg[P.size()] = {0};
    if(P.size()==1){
        nah = 1;
    }
    int root = -1;
    for(int i = 0;i<P.size();i++){
        int x = P[i];
        if(x==-1){
            root = i;
        }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){
    if(nah)return L;
    return cnt*L+max(0ll,(cnt*L-R));
}

Compilation message

tree.cpp: In function 'void init(std::vector<int>, std::vector<int>)':
tree.cpp:11:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i = 0;i<P.size();i++){
      |                   ~^~~~~~~~~
tree.cpp:20:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i = 0;i<P.size();i++){
      |                   ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 6704 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 49 ms 8476 KB Output is correct
2 Correct 57 ms 8352 KB Output is correct
3 Correct 49 ms 8352 KB Output is correct
4 Correct 51 ms 8332 KB Output is correct
5 Correct 52 ms 8488 KB Output is correct
6 Correct 48 ms 8232 KB Output is correct
7 Correct 52 ms 8352 KB Output is correct
8 Correct 47 ms 7468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 8476 KB Output is correct
2 Correct 57 ms 8352 KB Output is correct
3 Correct 49 ms 8352 KB Output is correct
4 Correct 51 ms 8332 KB Output is correct
5 Correct 52 ms 8488 KB Output is correct
6 Correct 48 ms 8232 KB Output is correct
7 Correct 52 ms 8352 KB Output is correct
8 Correct 47 ms 7468 KB Output is correct
9 Incorrect 51 ms 8352 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 6988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 33 ms 6704 KB Output isn't correct
3 Halted 0 ms 0 KB -