Submission #850139

#TimeUsernameProblemLanguageResultExecution timeMemory
850139divadSpeedrun (RMI21_speedrun)C++14
33 / 100
116 ms1620 KiB
#include <bits/stdc++.h> #include "speedrun.h" #define pii pair<int, int> using namespace std; const int NMAX = 1002; vector<int> v[NMAX]; int n,l,t[NMAX],tour[NMAX],pos[NMAX],k; int st[NMAX]; void euler(int nod, int tata = -1){ if(tata > 0){ t[nod] = tata; } if(!pos[nod]){ tour[++k] = nod; pos[nod] = k; } for(int fiu: v[nod]){ if(fiu == tata){ continue; } euler(fiu, nod); } } pii split(int x){ x >>= 1; int mask = (1<<10)-1; return {x&mask, x>>10}; } void assignHints (int subtask , int N, int A[], int B[]){ setHintLen(41); n = N; for(int i = 1; i < N; i++){ v[A[i]].push_back(B[i]); v[B[i]].push_back(A[i]); } euler(1); for(int i = 1; i <= n; i++){ int val = t[i] + ((tour[pos[i]+1]) << 10); val <<= 1; pii aux = split(val); for(int j = 1; j <= 20; j++){ int bt = ((val>>j)&1); setHint(i, j, bt); } } } int getWholeHint(){ int ans = 0; for(int i = 1; i <= 20; i++){ ans += (1<<i)*getHint(i); } return ans; } void speedrun(int subtask , int N, int start){ n = N; l = getLength(); while(start != 1){ int val = getWholeHint(); start = split(val).first; goTo(start); } int vf = 0; st[++vf] = 1; int cnt = 1; while(cnt != n){ int nxt = split(getWholeHint()).second; while(!goTo(nxt)){ vf--; goTo(st[vf]); } goTo(nxt); st[++vf] = nxt; cnt++; } }

Compilation message (stderr)

speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:44:13: warning: variable 'aux' set but not used [-Wunused-but-set-variable]
   44 |         pii aux = split(val);
      |             ^~~
#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...