Submission #1349645

#TimeUsernameProblemLanguageResultExecution timeMemory
1349645ahmetlbktd4Tree (IOI24_tree)C++20
Compilation error
0 ms0 KiB
#include "tree.h"
#include "bits/stdc++.h"
#define ll long long
using namespace std;

const int N = 2e5+5;

int n;
vector<int> p, w;
int k = 0; 
vector <int> g; 
int d[N];

void init(std::vector<int> P, std::vector<int> W){
  p = P;
  w = W;
  n = (int)p.size();
  g.resize(n);
  for (int i = 1;i < n;i++){
    g[p[i]].push_back(i);
  }
  // dfs(0,-1);
  for (int i = 0;i < n;i++){
    if (g[i].empty())
    k++;
  }
}

ll query(int L, int R){
  ll p = (ll)k*L + (ll)max(0ll,(ll)k*L-R);
  return p;
}

Compilation message (stderr)

tree.cpp: In function 'void init(std::vector<int>, std::vector<int>)':
tree.cpp:20:13: error: request for member 'push_back' in 'g.std::vector<int>::operator[](((std::vector<int>::size_type)p.std::vector<int>::operator[](((std::vector<int>::size_type)i))))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   20 |     g[p[i]].push_back(i);
      |             ^~~~~~~~~
tree.cpp:24:14: error: request for member 'empty' in 'g.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   24 |     if (g[i].empty())
      |              ^~~~~