# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
856205 | codecodru | Speedrun (RMI21_speedrun) | C++14 | 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 <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
const int MAXL = 325;
vector<int> adj[MAXN];
vector<int> hints[MAXN];
int l;
bool goTo(int x) {
return false;
}
void setHint(int node, int bitIndex, bool value) {
hints[node][bitIndex - 1] = value;
}
void setHintLen(int length) {
l = length;
}
void dfs(int v, int parent) {
for (int u : adj[v]) {
if (u == parent) continue;
if (hints[v][v] == 1) {
bool moved = goTo(u);
if (moved) dfs(u, v);
}
}
}
void assignHints(int subtask, int N, int A[], int B[]) {
if (subtask == 1) {
l = min(N, 20);
} else if (subtask == 2 || subtask == 3) {
l = min(20, N);
} else {
l = min(316, N);
}
setHintLen(l);
for (int i = 1; i <= N; i++) {
hints[i].resize(l);
}
for (int i = 1; i < N; i++) {
setHint(A[i], A[i], 1);
setHint(B[i], B[i], 1);
}
}
void speedrun(int subtask, int N, int start) {
vector<bool> visited(N + 1, false);
dfs(start, 0);
visited[start] = true;
int nodes_visited = 1;
while (nodes_visited < N) {
for (int i = 1; i <= N; i++) {
if (!visited[i] && hints[i][i] == 1) {
bool moved = goTo(i);
if (moved) {
visited[i] = true;
nodes_visited++;
}
}
}
}
}