#include <bits/stdc++.h>
#include "speedrun.h"
using namespace std;
int nnn;
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)
{
//cout << "oo " << nod << ' ' << tata << endl;
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);
nnn = N;
for (int i = 1; i < nnn; i++)
{
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
dfs(1, 0);
//for (int i = 1; i <= nnn; i++)
// cout << preord[i] << ' ';
//cout << endl;
for (int i = 1; i <= nnn; i++)
{
int nd = preord[i], urm = preord[i % nnn + 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;
nnn = N;
while (true)
{
int trg = u();
//cout << "uh " << nod << ' ' << trg << endl;
if (trg == start)
break;
while (true)
{
//cout << "wo " << nod << ' ' << tt() << endl;
if (nod == trg)
break;
if (goTo(trg))
{
nod = trg;
break;
}
//cout << "woo " << nod << ' ' << tt() << endl;
int lol = tt();
goTo(tt());
//cout << "wooo " << nod << ' ' << tt() << endl;
nod = lol;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
381 ms |
1352 KB |
Output is correct |
2 |
Correct |
338 ms |
1616 KB |
Output is correct |
3 |
Correct |
330 ms |
1104 KB |
Output is correct |
4 |
Correct |
356 ms |
1460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
346 ms |
1112 KB |
Output is correct |
2 |
Correct |
365 ms |
924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
343 ms |
1324 KB |
Output is correct |
2 |
Correct |
354 ms |
1316 KB |
Output is correct |
3 |
Correct |
354 ms |
1576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
381 ms |
1808 KB |
Output is correct |
2 |
Correct |
352 ms |
1104 KB |
Output is correct |
3 |
Correct |
334 ms |
924 KB |
Output is correct |
4 |
Correct |
374 ms |
1052 KB |
Output is correct |
5 |
Correct |
353 ms |
844 KB |
Output is correct |
6 |
Correct |
367 ms |
1104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
366 ms |
860 KB |
Output is correct |
2 |
Correct |
357 ms |
1108 KB |
Output is correct |
3 |
Correct |
364 ms |
952 KB |
Output is correct |
4 |
Correct |
358 ms |
1320 KB |
Output is correct |
5 |
Correct |
353 ms |
1132 KB |
Output is correct |
6 |
Correct |
350 ms |
848 KB |
Output is correct |
7 |
Correct |
402 ms |
916 KB |
Output is correct |