Submission #829770

#TimeUsernameProblemLanguageResultExecution timeMemory
829770raphaelpSpeedrun (RMI21_speedrun)C++14
Compilation error
0 ms0 KiB
#include "speedrun.h" #include <bits/stdc++.h> using namespace std; void assign(int i, int N, int slot) { for (int j = 9; j >= 0; j--) { setHint(i, j + (10 * slot), N % 2); N /= 2; } } int rec(int p, int x, vector<bool> &occ, vector<vector<int>> &Tree, int last) { occ[x] = 1; assign(p, x, 0); if (Tree[x].size() == 1) { assign(x, last, 0); } for (int i = 0; i < Tree[x].size(); ++i) { if (occ[Tree[x][i]]) { Tree[x].erase(i); i--; continue; } if (i != 0) { assign(Tree[x][i - 1], Tree[x][i], 1); } rec(x, Tree[x][i], occ, Tree, (i == Tree[x].size() - 1 || (i == Tree[x].size() - 2 && p == Tree[x][Tree[x].size() - 1])) ? last : x); } assign(Tree[x][Tree[x].size() - 1], x, 1); } void assignHints(int subtask, int N, int A[], int B[]) { vector<vector<int>> Tree(N); for (int i = 0; i < N - 1; i++) { Tree[A[i] - 1].push_back(B[i] - 1); Tree[B[i] - 1].push_back(A[i] - 1); } setHintLen(20); vector<bool> occ(N); rec(0, 0, occ, Tree, 0); } int read(int slot) { int sum = 0; for (int i = 0; i < 10; i++) { sum *= 2; sum += getHint(i + (10 * slot)); } return sum; } void speedrun(int subtask, int N, int start) { int x = start; deque<int> pile; vector<int> fils(N); vector<int> bro(N); vector<int> leaf(N); vector<bool> failed(N, false); vector<bool> failed2(N, false); vector<bool> occ(N, 0); int nbvis = 0; bool depile = false; while (nbvis < N) { if (!occ[x]) { bro[x] = read(1); fils[x] = read(0); } if (depile) { if (!occ[x]) nbvis++; occ[x] = 1; if (pile.size() > 1) { pile.pop_back(); leaf[pile.back()] = leaf[x]; bro[fils[pile.back()]] = bro[x]; x = pile.back(); depile = false; } else { pile.pop_back(); failed2[leaf[x]] = goTo(bro[leaf[x]]); if (failed2[leaf[x]]) { failed2[x] = goTo(bro[x]); pile.push_back(bro[x]); x = bro[x]; } else { x = bro[leaf[x]]; pile.push_back(x); depile = false; } } } else { if (pile.size() > 1 && fils[x] == pile[pile.size() - 2]) { leaf[x] = x; depile = true; } if (pile.front() == fils[x]) pile.pop_front(); if (occ[fils[x]]) { failed2[fils[x]] = goTo(bro[fils[x]]); if (!failed2[fils[x]]) { x = bro[fils[x]]; continue; } depile = true; } else { failed[x] = goTo(fils[x]); if (!failed[x]) { pile.push_back(fils[x]); x = fils[x]; continue; } } } } }

Compilation message (stderr)

speedrun.cpp: In function 'int rec(int, int, std::vector<bool>&, std::vector<std::vector<int> >&, int)':
speedrun.cpp:21:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for (int i = 0; i < Tree[x].size(); ++i)
      |                     ~~^~~~~~~~~~~~~~~~
speedrun.cpp:25:28: error: no matching function for call to 'std::vector<int>::erase(int&)'
   25 |             Tree[x].erase(i);
      |                            ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from speedrun.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1430:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator]'
 1430 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1430:28: note:   no known conversion for argument 1 from 'int' to 'std::vector<int>::const_iterator'
 1430 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1457:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator]'
 1457 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1457:7: note:   candidate expects 2 arguments, 1 provided
speedrun.cpp:33:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         rec(x, Tree[x][i], occ, Tree, (i == Tree[x].size() - 1 || (i == Tree[x].size() - 2 && p == Tree[x][Tree[x].size() - 1])) ? last : x);
      |                                        ~~^~~~~~~~~~~~~~~~~~~~~
speedrun.cpp:33:70: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         rec(x, Tree[x][i], occ, Tree, (i == Tree[x].size() - 1 || (i == Tree[x].size() - 2 && p == Tree[x][Tree[x].size() - 1])) ? last : x);
      |                                                                    ~~^~~~~~~~~~~~~~~~~~~~~
speedrun.cpp:36:1: warning: no return statement in function returning non-void [-Wreturn-type]
   36 | }
      | ^