/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")*/
#include <bits/stdc++.h>
#include "speedrun.h"
#define for1(i,a,b) for (int i = a; i <= b; i++)
#define for2(i,a,b) for (int i = a; i >= b; i--)
// #define int long long
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pb push_back
/*
__builtin_popcountll(x) : Number of 1-bit
__builtin_ctzll(x) : Number of trailing 0
*/
const long double PI = 3.1415926535897932384626433832795;
// const int INF = 1000000000000000000;
const int MOD = 1000000007;
const int MOD2 = 1000000009;
const long double EPS = 1e-6;
using namespace std;
int now, tin[1005], rev[1005];
vector<int> g[1005];
void dfs(int u, int p) {
for1(i,0,9) if (p & (1 << i)) setHint(u, i + 1, 1);
tin[u] = ++now;
rev[now] = u;
for (auto v : g[u]) if (v != p) dfs(v, u);
}
void assignHints(int subtask, int n, int a[], int b[]) {
setHintLen(20);
for1(i,1,n - 1) {
g[a[i]].push_back(b[i]);
g[b[i]].push_back(a[i]);
}
dfs(1, 0);
for1(u,1,n) {
for1(i,0,9) if (rev[tin[u] + 1] & (1 << i)) setHint(u, i + 11, 1);
}
return;
}
int get(int p) {
int res = 0;
for1(i,0,9) {
bool t = getHint(i + 1 + p * 10);
res ^= (t << i);
}
return res;
}
void speedrun(int subtask, int n, int u) {
int l = getLength();
while (1) {
int v = get(0);
if (!v) break;
goTo(v);
u = v;
}
int flag = 1, cur = get(1);
while (1) {
if (!flag) {
cur = get(1);
flag = 1;
}
if (!cur) return;
if (goTo(cur)) {
u = cur;
flag = 0;
}
else {
int v = get(0);
goTo(v);
u = v;
}
}
}
Compilation message
speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:64:6: warning: unused variable 'l' [-Wunused-variable]
64 | int l = getLength();
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
119 ms |
816 KB |
Output is correct |
2 |
Correct |
119 ms |
740 KB |
Output is correct |
3 |
Correct |
86 ms |
692 KB |
Output is correct |
4 |
Correct |
130 ms |
872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
756 KB |
Output is correct |
2 |
Correct |
91 ms |
712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
98 ms |
776 KB |
Output is correct |
2 |
Correct |
95 ms |
764 KB |
Output is correct |
3 |
Correct |
80 ms |
832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
122 ms |
824 KB |
Output is correct |
2 |
Correct |
152 ms |
932 KB |
Output is correct |
3 |
Correct |
158 ms |
692 KB |
Output is correct |
4 |
Correct |
112 ms |
760 KB |
Output is correct |
5 |
Correct |
106 ms |
828 KB |
Output is correct |
6 |
Correct |
142 ms |
796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
122 ms |
696 KB |
Output is correct |
2 |
Correct |
87 ms |
880 KB |
Output is correct |
3 |
Correct |
97 ms |
660 KB |
Output is correct |
4 |
Correct |
106 ms |
824 KB |
Output is correct |
5 |
Correct |
132 ms |
784 KB |
Output is correct |
6 |
Correct |
136 ms |
868 KB |
Output is correct |
7 |
Correct |
76 ms |
696 KB |
Output is correct |