Submission #701761

#TimeUsernameProblemLanguageResultExecution timeMemory
701761EtheriteSpeedrun (RMI21_speedrun)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "speedrun.h" using namespace std; void assignHints(int subtask, int N, int A[], int B[]) { setHintLen(20); vector<vector<int>> adjHint(N + 1); for(int i = 1; i < N; i++) { adjHint[A[i]].push_back(B[i]); adjHint[B[i]].push_back(A[i]); } for(int i = 1; i <= N; i++) sort(adjHint[i].begin(), adjHint[i].end()); stack<int> toAdd; dfsHint(1, 0, adjHint, toAdd); } void dfsHint(int curr, int par, vector<set<int>> &adjHint, stack<int> &toAdd) { for(int i = 9; i >= 0; i--) // set in big-endian { if(par & (1 << i)) setHint(curr, i + 1, 1); else setHint(curr, i + 1, 0); } for(int i = adjHint[curr].size() - 1; i >= 0; i--) { int next = adjHint[i]; if(next == par) continue; toAdd.push(next); } int second = toAdd.top(); toAdd.pop(); for(int i = 9; i >= 0; i--) { if(second & (1 << i)) setHint(curr, i + 11, 1); else setHint(curr, i + 11, 0); } for(int next : adjHint[curr]) { if(next == par) continue; dfsHint(next, curr, adjHint, toAdd); } } void speedrun(int subtask, int N, int start) { int l = getLength(); int par = 0; for(int i = 0; i < 10; i++) par += getHint(i + 1) * (1 << i); vector<int> vis(N + 1); vis[start] = 1; dfsSpeedrun(start, par, vis); } int dfsSpeedrun(int curr, int par, vector<int> &vis) { int child = 0; for(int i = 10; i < 20; i++) child += getHint(i + 1) * (1 << (i - 10)); while(1) { bool canDescend = goTo(child); if(canDescend) { child = dfsSpeedrun(child, curr); } else return child; } }

Compilation message (stderr)

speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:17:2: error: 'dfsHint' was not declared in this scope
   17 |  dfsHint(1, 0, adjHint, toAdd);
      |  ^~~~~~~
speedrun.cpp: In function 'void dfsHint(int, int, std::vector<std::set<int> >&, std::stack<int>&)':
speedrun.cpp:30:23: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::set<int> >, std::set<int> >::value_type' {aka 'std::set<int>'} to 'int' in initialization
   30 |   int next = adjHint[i];
      |                       ^
speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:58:2: error: 'dfsSpeedrun' was not declared in this scope; did you mean 'speedrun'?
   58 |  dfsSpeedrun(start, par, vis);
      |  ^~~~~~~~~~~
      |  speedrun
speedrun.cpp:51:6: warning: unused variable 'l' [-Wunused-variable]
   51 |  int l = getLength();
      |      ^
speedrun.cpp: In function 'int dfsSpeedrun(int, int, std::vector<int>&)':
speedrun.cpp:71:35: error: too few arguments to function 'int dfsSpeedrun(int, int, std::vector<int>&)'
   71 |    child = dfsSpeedrun(child, curr);
      |                                   ^
speedrun.cpp:61:5: note: declared here
   61 | int dfsSpeedrun(int curr, int par, vector<int> &vis)
      |     ^~~~~~~~~~~