Submission #701788

#TimeUsernameProblemLanguageResultExecution timeMemory
701788EtheriteSpeedrun (RMI21_speedrun)C++17
0 / 100
3572 ms736 KiB
#include <bits/stdc++.h> #include "speedrun.h" using namespace std; void dfsHint(int curr, int par, vector<vector<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[curr][i]; if(next == par) continue; toAdd.push(next); } if(!toAdd.empty()) { 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 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); } pair<int, int> dfs(int curr, int toTry, set<int> &vis) // returns (next curr, value to try) { vis.insert(curr); int par = 0, child = 0; for(int i = 0; i < 10; i++) par += getHint(i + 1) * (1 << i); for(int i = 10; i < 20; i++) child += getHint(i + 1) * (1 << (i - 10)); if(toTry == 0) toTry = child; if(toTry == 0) return make_pair(par, 0); if(goTo(toTry)) { pair<int, int> res = dfs(toTry, 0, vis); return make_pair(par, res.second); } else return make_pair(par, toTry); } void speedrun(int subtask, int N, int start) { if(N == 1) return; int l = getLength(); set<int> vis; pair<int, int> next = make_pair(start, 0); while(vis.size() < N) { next = dfs(next.first, next.second, vis); } }

Compilation message (stderr)

speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:78:19: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   78 |  while(vis.size() < N)
      |        ~~~~~~~~~~~^~~
speedrun.cpp:74:6: warning: unused variable 'l' [-Wunused-variable]
   74 |  int l = getLength();
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...