#include <bits/stdc++.h>
#include "speedrun.h"
using namespace std;
int n;
vector<int> g[1005];
int preord[1005], cr;
bool ff(int x)
{
if (x == 0)
return false;
return true;
}
void dfs(int nod, int tata)
{
preord[++cr] = nod;
for (int i = 0; i < 10; i++)
setHint(nod, i + 1, ff(tata & (1 << i)));
for (auto vecin : g[nod])
if (vecin != tata)
dfs(vecin, nod);
}
void assignHints(int subtask, int N, int A[], int B[])
{
setHintLen(20);
n = N;
for (int i = 1; i < n; i++)
{
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
dfs(1, 0);
for (int i = 1; i <= n; i++)
{
int nd = preord[i], urm = preord[i % n + 1];
for (int j = 10; j < 20; j++)
setHint(nd, j + 1, ff(urm & (1 << (j - 10))));
}
}
int u()
{
int x = 0;
for (int i = 10; i < 20; i++)
{
if (getHint(i + 1))
x += (1 << (i - 10));
}
return x;
}
int tt()
{
int x = 0;
for (int i = 0; i < 10; i++)
{
if (getHint(i + 1))
x += (1 << i);
}
return x;
}
void speedrun(int subtask, int N, int start)
{
int nod = start;
n = N;
while (true)
{
int trg = u();
if (trg == start)
break;
while (true)
{
if (nod == trg)
break;
if (goTo(trg))
{
nod = trg;
break;
}
goTo(tt());
nod = tt();
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
323 ms |
724 KB |
Solution didn't visit every node |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
422 ms |
844 KB |
Used too many wrong interactions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
331 ms |
1128 KB |
Solution didn't visit every node |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1861 ms |
844 KB |
Used too many wrong interactions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
365 ms |
1104 KB |
Output is correct |
2 |
Incorrect |
353 ms |
1112 KB |
Solution didn't visit every node |
3 |
Halted |
0 ms |
0 KB |
- |