# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1119351 | Bula | Speedrun (RMI21_speedrun) | C++17 | 213 ms | 1388 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 "speedrun.h"
#include<bits/stdc++.h>
using namespace std;
const int Nx = 1e3 + 5;
vector<int> adj[Nx], par(Nx), ord;
void dfs(int v, int p){
par[v] = p;
ord.push_back(v);
for(auto x : adj[v]){
if(x == p) continue;
dfs(x, v);
}
}
void assignHints(int subtask, int n, int A[], int B[]){
for(int i = 1; i <= n - 1; i++){
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
setHintLen(20);
dfs(1, 0);
for(int i = 1; i <= n; i++){
for(int j = 0; j < 10; j++){
if(par[i] & (1 << j)) setHint(i, j + 1, 1);
}
}
for(int i = 1; i < ord.size(); i++){
for(int j = 0; j < 10; j++){
if(ord[i] & (1 << j)) setHint(ord[i - 1], j + 11, 1);
}
}
}
void speedrun(int subtask, int n, int start){
while(start != 1){
int p = 0;
for(int j = 1; j <= 10; j++){
p += getHint(j) * (1 << (j - 1));
}
goTo(p);
start = p;
}
set<int> st;
int targ = 0, cur = start;
while(st.size() < n){
st.insert(cur);
int p = 0, nxt = 0;
for(int j = 1; j <= 10; j++){
p += getHint(j) * (1 << (j - 1));
nxt += getHint(j + 10) * (1 << (j - 1));
}
if(targ > 0 && goTo(targ)){
cur = targ;
targ = 0;
}else if(nxt > 0 && st.find(nxt) == st.end() && goTo(nxt)){
cur = nxt;
}
else{
goTo(p);
cur = p;
if(targ == 0) targ = nxt;
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |