#include "speedrun.h"
#include <bits/stdc++.h>
#define FOR(v, s, e) for (int v = s; v < e; v++)
using namespace std;
void assignHints(int subtask, int N, int A[], int B[]) {
if (subtask == 1) {
setHintLen(N);
FOR(i, 1, N) {
setHint(A[i], B[i], 1);
setHint(B[i], A[i], 1);
}
} else if (subtask == 2) {
int centre = 0;
if (N == 2) {
centre = A[0];
} else if (N > 2) {
int x1 = A[1], x2 = B[1];
int y1 = A[2], y2 = B[2];
if (x1 == y1 || x1 == y2) {
centre = x1;
} else {
centre = x2;
}
}
cout << centre;
int bits[20], i = 0;
for (;centre > 0 && i < 20;i++) {
bits[i] = centre & 1;
centre >>= 1;
}
setHintLen(i + 1);
FOR(nd, 1, N + 1) {
FOR(j, 0, i) {
setHint(nd, j, bits[j]);
}
}
}
}
void dfs(int nd, int par, int n) {
vector<int> possible;
FOR(i, 0, n) {
if (getHint(i + 1) == 1) {
possible.push_back(i + 1);
}
}
for(int node : possible) {
if (node == par) continue;
goTo(node);
dfs(node, nd, n);
}
if (par != -1) goTo(par);
}
void speedrun(int subtask, int N, int start) {
if (subtask == 1) {
dfs(start, -1, N);
} else if (subtask == 2) {
int bits[20];
FOR(i, 0, 20) {
bits[i] = getHint(i);
}
int centre = 0;
FOR(i, 0, getLength()) {
centre = (centre << 1) + bits[i];
}
if (start != centre) goTo(centre);
FOR(i, 1, N + 1) {
if (i != centre && i != start) {
goTo(i); goTo(centre);
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
792 KB |
Output is correct |
2 |
Correct |
40 ms |
820 KB |
Output is correct |
3 |
Correct |
37 ms |
920 KB |
Output is correct |
4 |
Correct |
35 ms |
808 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
assignHints must not call getHint, getLength or goTo |
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 |
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 |
- |