Submission #966985

#TimeUsernameProblemLanguageResultExecution timeMemory
966985AtabayRajabliSpeedrun (RMI21_speedrun)C++17
0 / 100
79 ms1920 KiB
#include "speedrun.h" #include <bits/stdc++.h> using namespace std; const int sz = 2005; int cnt, num, in[sz], t[sz], p[sz]; vector<int> g[sz]; void dfs(int v) { in[v] = ++cnt; t[in[v]] = v; for(int i : g[v]) { if(!in[i]) { p[i] = v; dfs(i); } } } void assignHints(int subtask, int N, int A[], int B[]) { for(int i = 1; i <= N - 1; i++) { g[A[i]].push_back(B[i]); g[B[i]].push_back(A[i]); } setHintLen(20); dfs(1); for(int i = 1; i <= N; i++) { int nxt = t[in[i] + 1]; int prv = p[i]; int h = 0; for(int j = 0; j < 10; j++) { if(prv & (1 << j)) setHint(i, (j + 11), 1); if(nxt & (1 << j)) setHint(i, (j + 1), 1); } } } void f(int go, int N) { if(num > N)return; int nxt = 0, prv = 0; for(int i = 0; i < 10; i++) { nxt += getHint(i + 1) * (1 << i); prv += getHint(i + 11) * (1 << i); } if(go) { if(!goTo(go)) { // cout << "could not go to " << go << ", went to " << prv << endl; goTo(prv); f(go, N); } else { num++; // cout << "went to " << go << endl; f(0, N); } } else { if(!goTo(nxt)) { goTo(prv); //cout << "could not go to " << nxt << ", went to " << prv << endl; f(nxt, N); } else { //cout << "went to " << nxt << endl; num++; f(0, N); } } } void speedrun(int subtask, int N, int start) { num = 1; f(0, N); }

Compilation message (stderr)

speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:37:13: warning: unused variable 'h' [-Wunused-variable]
   37 |         int h = 0;
      |             ^
#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...