#include <bits/stdc++.h>
#include "speedrun.h"
#define pii pair<int, int>
using namespace std;
const int NMAX = 1002;
vector<int> v[NMAX];
int n,l,t[NMAX],tour[NMAX],pos[NMAX],k;
int st[NMAX];
void euler(int nod, int tata = -1){
if(tata > 0){
t[nod] = tata;
}
if(!pos[nod]){
tour[++k] = nod;
pos[nod] = k;
}
for(int fiu: v[nod]){
if(fiu == tata){
continue;
}
euler(fiu, nod);
}
}
pii split(int x){
x >>= 1;
int mask = (1<<10)-1;
return {x&mask, x>>10};
}
void assignHints (int subtask , int N, int A[], int B[]){
setHintLen(20);
n = N;
for(int i = 1; i < N; i++){
v[A[i]].push_back(B[i]);
v[B[i]].push_back(A[i]);
}
euler(1);
for(int i = 1; i <= n; i++){
int val = t[i] + ((tour[pos[i]+1]) << 10);
val <<= 1;
pii aux = split(val);
for(int j = 1; j <= 20; j++){
int bt = ((val>>j)&1);
setHint(i, j, bt);
}
}
}
int getWholeHint(){
int ans = 0;
for(int i = 1; i <= 20; i++){
ans += (1<<i)*getHint(i);
}
return ans;
}
void speedrun(int subtask , int N, int start){
n = N;
l = getLength();
while(start != 1){
int val = getWholeHint();
start = split(val).first;
goTo(start);
}
int vf = 0;
st[++vf] = 1;
int cnt = 1;
while(cnt != n){
int nxt = split(getWholeHint()).second;
while(!goTo(nxt)){
vf--;
goTo(st[vf]);
}
goTo(nxt);
st[++vf] = nxt;
cnt++;
}
}
Compilation message
speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:44:13: warning: variable 'aux' set but not used [-Wunused-but-set-variable]
44 | pii aux = split(val);
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
112 ms |
1608 KB |
Output is correct |
2 |
Correct |
116 ms |
1620 KB |
Output is correct |
3 |
Correct |
112 ms |
1752 KB |
Output is correct |
4 |
Correct |
104 ms |
1620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
112 ms |
1364 KB |
Output is correct |
2 |
Correct |
96 ms |
1508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
95 ms |
1376 KB |
Output is correct |
2 |
Correct |
100 ms |
1616 KB |
Output is correct |
3 |
Correct |
96 ms |
1412 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
97 ms |
1772 KB |
Output is correct |
2 |
Correct |
102 ms |
1540 KB |
Output is correct |
3 |
Correct |
94 ms |
1364 KB |
Output is correct |
4 |
Correct |
109 ms |
1620 KB |
Output is correct |
5 |
Correct |
105 ms |
1520 KB |
Output is correct |
6 |
Correct |
96 ms |
1532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
113 ms |
1864 KB |
Output is correct |
2 |
Correct |
100 ms |
1360 KB |
Output is correct |
3 |
Correct |
106 ms |
2032 KB |
Output is correct |
4 |
Correct |
89 ms |
1620 KB |
Output is correct |
5 |
Correct |
94 ms |
1280 KB |
Output is correct |
6 |
Correct |
99 ms |
1540 KB |
Output is correct |
7 |
Correct |
96 ms |
1104 KB |
Output is correct |