Submission #1270558

#TimeUsernameProblemLanguageResultExecution timeMemory
1270558efegSpeedrun (RMI21_speedrun)C++20
100 / 100
33 ms496 KiB
#include <bits/stdc++.h> #include "speedrun.h" using namespace std; #define pb push_back const int N = 1024; vector<int> par(N,1023),nxt(N,1023); vector<int> adj[N]; vector<int> liste; void dfs(int node,int p){ if (p != -1) par[node] = p; liste.pb(node); for (auto x : adj[node]){ if (x == p) continue; dfs(x,node); } } void assignHints(int subtask, int n, int a[], int b[]) { for (int i = 1; i < n; i++){ adj[a[i]-1].pb(b[i]-1); adj[b[i]-1].pb(a[i]-1); } dfs(0,-1); for (int i = 0; i < n; i++){ nxt[liste[i]] = liste[(i+1) % n]; } setHintLen(20); for (int node = 0; node < n; node++){ for (int bit = 0; bit < 10; bit++){ if (nxt[node] & (1 << bit)){ setHint(node+1,bit + 1,1); } } for (int bit = 0; bit < 10; bit++){ if (par[node] & (1 << bit)){ setHint(node+1,bit + 11,1); } } } } void speedrun(int subtask, int n, int start) { int l = getLength(); vector<int> ans(n + 10,0); int cnt = 0; int curr = start-1; int nxt = -1,par = 0; while (cnt < n) { if (ans[curr] == 0) cnt++; ans[curr] = 1; par = 0; if (nxt == -1){ nxt = 0; for (int bit = 0; bit < 10; bit++){ if (getHint(bit+1)) nxt += (1 << bit); } } for (int bit = 0; bit < 10; bit++){ if (getHint(bit+11)) par += (1 << bit); } //cout << curr+1 << " " << nxt+1 << " " << par+1 << " " << cnt << endl; if (goTo(nxt+1)){ curr = nxt; nxt = -1; } else { goTo(par+1); curr = par; } } }
#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...