#include "speedrun.h"
#include <bits/stdc++.h>
//~ #include <ext/pb_ds/assoc_container.hpp>
//~ using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
//~ typedef tree <ll, null_type, less_equal <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) ll((v).size())
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define OK cout << "OK" << endl;
const int MAXN = 1e3+7;
vector <int> graph[MAXN];
int parent[MAXN];
vector <int> stacc, used(MAXN);
int n;
int len;
void set_to_child(int from, int to) {
for (int bit = 0; bit < 10; bit++) {
if (to & (1 << bit)) {
setHint(from, bit+1, 1);
}
}
}
void set_to_parent(int from, int to) {
for (int bit = 0; bit < 10; bit++) {
if (to & (1 << bit)) {
setHint(from, bit+11, 1);
}
}
}
void set_dfs(int v, int p = 0) {
if (used[v]) {
return;
}
parent[v] = p;
used[v] = 1;
stacc.pb(v);
for (auto to : graph[v]) {
set_dfs(to, v);
}
}
void assignHints(int subtask, int N, int A[], int B[]) { /* your solution here */
setHintLen(20);
n = N;
for (int i = 1; i < n; i++) {
graph[A[i]].pb(B[i]);
graph[B[i]].pb(A[i]);
}
set_dfs(1);
for (int i = 0; i < sz(stacc); i++) {
set_to_child(stacc[i], stacc[(i+1)%n]);
set_to_parent(stacc[i], parent[stacc[i]]);
}
}
int get_child() {
int res = 0;
for (int bit = 0; bit < 10; bit++) {
if (getHint(bit+1)) {
res += (1 << bit);
}
}
return res;
}
int get_parent() {
int res = 0;
for (int bit = 0; bit < 10; bit++) {
if (getHint(bit+11)) {
res += (1 << bit);
}
}
return res;
}
/*
5
1 2
2 3
3 4
3 5
2
*/
void speedrun(int subtask, int N, int start) { /* your solution here */
len = getLength();
while (start != 1) {
goTo(start = get_parent());
}
set <int> st;
int nxt = 0;
while (sz(st) < N) {
st.insert(start);
if (nxt) {
pii a = mp(get_child(), get_parent());
goTo(nxt);
pii b = mp(get_child(), get_parent());
if (a == b) {
goTo(start = get_parent());
nxt = 0;
}
else {
start = nxt;
}
}
else {
pii a = mp(get_child(), get_parent());
int ch = get_child();
goTo(ch);
pii b = mp(get_child(), get_parent());
if (a == b) {
nxt = ch;
goTo(start = get_parent());
}
else {
start = ch;
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
81 ms |
700 KB |
Used too many wrong interactions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
113 ms |
660 KB |
Used too many wrong interactions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
134 ms |
736 KB |
Used too many wrong interactions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
991 ms |
660 KB |
Used too many wrong interactions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
154 ms |
688 KB |
Used too many wrong interactions |
2 |
Halted |
0 ms |
0 KB |
- |