| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1097380 | heeheeheehaaw | Speedrun (RMI21_speedrun) | C++17 | 139 ms | 1132 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>
#include "speedrun.h"
using namespace std;
vector<int> adj[1005];
bool visited[1005];
vector<int> ord;
int parent[1005];
int vis[1005];
void dfs(int nod, int par)
{
parent[nod] = par;
if(!visited[nod])
visited[nod] = true, ord.push_back(nod);
for(auto it : adj[nod])
{
if(it != par)
dfs(it, nod);
}
}
void assignHints(int subtask, int n, int a[], int b[])
{
setHintLen(20);
for(int i = 1; i < n; i++)
{
adj[a[i]].push_back(b[i]);
adj[b[i]].push_back(a[i]);
}
dfs(1, 1);
for(int i = 0; i < ord.size() - 1; i++)
{
for(int b = 0; b < 10; b++)
{
if(((1 << b) & (ord[i + 1])) != 0)
setHint(ord[i], b + 1, 1);
else
setHint(ord[i], b + 1, 0);
}
}
for(int i = 0; i < ord.size(); i++)
{
for(int b = 0; b < 10; b++)
{
if(((1 << b) & parent[ord[i]]) != 0)
setHint(ord[i], b + 1 + 10, 1);
else
setHint(ord[i], b + 1 + 10, 0);
}
}
for(int b = 0; b < 10; b++)
{
if(((1 << b) & (ord[0])) != 0)
setHint(ord.back(), b + 1, 1);
else
setHint(ord.back(), b + 1, 0);
}
}
void speedrun(int subtask, int n, int start)
{
int curr = start, cnt = n, nxt = -1;
while(cnt > 0)
{
if(vis[curr] == 0)
cnt--, vis[curr] = 1;
int u = 0, par = 0;
for(int i = 1; i <= 10; i++)
u += (1 << (i - 1)) * getHint(i);
if(nxt != -1)
u = nxt;
for(int i = 11; i <= 20; i++)
par += (1 << (i - 1 - 10)) * getHint(i);
bool ok = goTo(u);
if(ok == true)
{
curr = u;
nxt = -1;
}
else
{
goTo(par);
curr = par;
nxt = u;
}
}
return;
}
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... | ||||
