Submission #504889

#TimeUsernameProblemLanguageResultExecution timeMemory
504889TranGiaHuy1508Speedrun (RMI21_speedrun)C++17
0 / 100
1 ms328 KiB
#include <bits/stdc++.h> using namespace std; #include "speedrun.h" using vi = vector<int>; using vvi = vector<vi>; #define pb push_back void fset(int x, int pos, int val){ int y = 0; if (pos) y += 10; for (int c = 0; c < 10; c++){ setHint(x, y+c, (bool)((val >> (9 - c)) & 1)); } } int fget(int pos){ int y = 0; if (pos) y += 10; int res = 0; for (int c = 0; c < 10; c++){ res = res * 2 + (int)(getHint(y+c)); } return res; } vvi adj; vi dfsorder, parent; void dfs(int x, int p = -1){ dfsorder.pb(x); parent[x] = (p < 0 ? 1022 : p); for (auto k: adj[x]){ if (k - p){ dfs(k, x); } } } void assignHints(int subtask, int N, int a[], int b[]){ setHintLen(20); adj.assign(N, vi()); for (int i=1; i<N; i++){ adj[a[i] - 1].pb(b[i] - 1); adj[b[i] - 1].pb(a[i] - 1); } parent.assign(N, 1022); dfs(0); for (int i=0; i<N; i++){ fset(i+1, 0, parent[i] + 1); } for (int i=0; i<(int)dfsorder.size()-1; i++){ fset(dfsorder[i] + 1, 1, dfsorder[i] + 1); } } void speedrun(int subtask, int N, int start){ // getLength() = 20 int c = start; int p = fget(0); while (p < 1020){ goTo(p); c = p; p = fget(0); } // at root vi r(N, 0); int sm = 1; r[c] = 1; while (sm < N){ int val = fget(1); bool test = goTo(val); while (!test){ goTo(fget(0)); test = goTo(val); } c = val; sm -= r[c]; r[c] = 1; sm++; } }
#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...