Submission #1046569

#TimeUsernameProblemLanguageResultExecution timeMemory
10465690npataBeech Tree (IOI23_beechtree)C++17
Compilation error
0 ms0 KiB
#include "beechtree.h" #include<bits/stdc++.h> using namespace std; int n, m; vector<int> p, c; vector<vector<int>> g; int good(int r){ vector<int> ch; queue<int> q; q.push(r); while(!q.empty()){ int n = q.front(); q.pop(); ch.push_back(node); for (int i : g[node]) q.push(i); } if (ch.size() == 1) return 1; bool jupi = false; do { vector<int> count(m, 0); vector<int> is(ch.size(), -1); is[0] = r; bool good = true; for (int i = 0; i < ch.size() && good; i++){ if (ch[i] == r) continue; if (count[c[ch[i]]] >= is.size() || p[ch[i]] != is[count[c[ch[i]]]]) good = false; count[c[ch[i]]]++; if (i+1 < is.size()) is[i+1] = ch[i]; } if (good){ jupi = true; } } while(next_permutation(ch.begin(), ch.end())); if (jupi) return 1; return 0; } std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C) { n = N; m = M; p = P; c = C; g.resize(n); for (int i = 1; i < n; i++){ if (p[i] < g.size()) { g[p[i]].push_back(i); } } vector<int> res(n); for (int i = 0; i < n; i++){ res[i] = good(i); } return res; }

Compilation message (stderr)

beechtree.cpp: In function 'int good(int)':
beechtree.cpp:14:22: error: 'node' was not declared in this scope
   14 |         ch.push_back(node);
      |                      ^~~~
beechtree.cpp:13:13: warning: unused variable 'n' [-Wunused-variable]
   13 |         int n = q.front(); q.pop();
      |             ^
beechtree.cpp:27:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         for (int i = 0; i < ch.size() && good; i++){
      |                         ~~^~~~~~~~~~~
beechtree.cpp:29:33: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |             if (count[c[ch[i]]] >= is.size() || p[ch[i]] != is[count[c[ch[i]]]]) good = false;
beechtree.cpp:31:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             if (i+1 < is.size()) is[i+1] = ch[i];
      |                 ~~~~^~~~~~~~~~~
beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:52:18: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         if (p[i] < g.size()) {