# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
857622 | lbadea1000 | Speedrun (RMI21_speedrun) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
using namespace std;
//#include "speedrun.h"
const int NMAX = 1000;
vector<int> edges[NMAX + 1];
int parent[NMAX + 1];
int nextInOrder[NMAX + 2];
int orderTime;
void dfs(int node, int par) {
parent[node] = par;
nextInOrder[orderTime++] = node;
for(auto child : edges[node]) {
if(child != par)
dfs(child, node);
}
}
void assignHints (int subtask , int N, int A[], int B[]) {
for(int i = 1; i <= N - 1; i++) {
edges[A[i]].push_back(B[i]);
edges[B[i]].push_back(A[i]);
}
int l = 10;
setHintLen(2 * l);
orderTime = 1;
dfs(1, 0);
nextInOrder[N + 1] = 1;
for(int i = 1; i <= N; i++) {
for(int bit = 0; bit < l; bit++) {
setHint(nextInOrder[i], bit + 1, parent[nextInOrder[i]] & (1 << bit));
setHint(nextInOrder[i], bit + l + 1, nextInOrder[i + 1] & (1 << bit));
}
}
}
void speedrun(int subtask , int N, int start ) {
/*int node = start;
int l = getLength ();
for(int i = 1; i <= N - 1; i++) {
int par, nextNode;
par = nextNode = 0;
for(int bit = 0; bit < l; bit++) {
par += (1 << bit) * getHint(bit + 1);
nextNode += (1 << bit) * getHint(bit + 1 + l);
}
while(goTo(nextNode) == false) {
node = par;
goTo(node);
par = 0;
for(int bit = 0; bit < l; bit++)
par += (1 << bit) * getHint(bit + 1);
}
node = nextNode;
}*/
}