#include "speedrun.h"
#include <bits/stdc++.h>
using namespace std;
void assignHints(int subtask, int N, int A[], int B[]) {
if (subtask == 1) {
setHintLen(N);
for (int i = 1; i < N; ++i) setHint(A[i],B[i],1), setHint(B[i],A[i],1);
}
if (subtask == 2) {
int deg[N+5];
memset(deg,0,sizeof(deg));
for (int i = 1; i < N; ++i) deg[A[i]]++, deg[B[i]]++;
int x = 1;
for (int i = 1; i <= N; ++i) if (deg[i] > deg[x]) x = i;
setHintLen(20);
for (int i = 0; i < 20; ++i) for (int j = 1; j <= N; ++j) if (x & (1<<i)) setHint(j,i+1,1);
}
}
int n;
void dfs (int x, int p) {
for (int i = 1; i <= n; ++i) if (i != p && getHint(i)) {
goTo(i);
dfs(i,x);
}
if (p != -1) goTo(p);
}
void speedrun(int subtask, int N, int start) {
int len = getLength();
if (subtask == 1) {
n = N;
dfs(start,-1);
}
if (subtask == 2) {
bitset<1005> visited;
visited[start] = 1;
int x = 0;
for (int i = 0; i < 20; ++i) if (getHint(i+1)) x |= (1<<i);
if (start != x) goTo(x), visited[x] = 1;
for (int i = 1; i <= N; ++i) if (!visited[i]) goTo(i), goTo(x);
}
}
Compilation message
speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:32:9: warning: unused variable 'len' [-Wunused-variable]
32 | int len = getLength();
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
744 KB |
Output is correct |
2 |
Correct |
36 ms |
772 KB |
Output is correct |
3 |
Correct |
41 ms |
792 KB |
Output is correct |
4 |
Correct |
35 ms |
796 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
712 KB |
Output is correct |
2 |
Correct |
41 ms |
672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
setHintLen was never called |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
setHintLen was never called |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
setHintLen was never called |
2 |
Halted |
0 ms |
0 KB |
- |