Submission #1095580

# Submission time Handle Problem Language Result Execution time Memory
1095580 2024-10-02T15:08:20 Z peti1234 Speedrun (RMI21_speedrun) C++17
0 / 100
64 ms 1108 KB
#include <bits/stdc++.h>
#include "speedrun.h"
using namespace std;

const int c=1005;
int n, fel[c];
vector<int> sz[c], sor;
bool v[c];

void dfs(int a) {
	v[a]=true;
	sor.push_back(a);
	for (auto x:sz[a]) {
		if (!v[x]) {
			fel[x]=a;
			dfs(x);
		}
	}
}

void assignHints(int st, int N, int A[], int B[]) {
	n=N;
	for (int i=0; i<n-1; i++) {
		int x=A[i], y=B[i];
		sz[x].push_back(y), sz[y].push_back(x);
	}


	dfs(1);


	 setHintLen(20);
	 for (int i=1; i<=n; i++) {
		 for (int j=0; j<10; j++) {
			 if (fel[i] & (1<<j)) {
				 setHint(i, j+1, 1);
			 }
		 }
	 }
	 for (int i=0; i<n-1; i++) {
		 int a=sor[i], b=sor[i+1];
		 for (int j=0; j<10; j++) {
			 if (b & (1<<j)) {
				 setHint(a, j+11, 1);
			 }
		 }
	 }

}

int felett() {
	int res=0;
	for (int i=0; i<10; i++) {
		if (getHint(i+1)) {
			res+=(1<<i);
		}
	}
	return res;
}
int kov() {
	int res=0;
	for (int i=0; i<10; i++) {
		if (getHint(i+11)) {
			res+=(1<<i);
		}
	}
	return res;
}

bool lep(int a) {
	return goTo(a);
}

void speedrun(int st, int N, int pos) {
	n=N;
	while (pos!=1) {
		int s=felett();
		lep(s);
		pos=s;
	}

	int cel=kov();

	for (int i=1; i<n; i++) {
		while (!lep(cel)) {
			int f=felett();
			lep(f);
			pos=f;
		}
		pos=cel;
		cel=kov();
	}

	return;
}
# Verdict Execution time Memory Grader output
1 Incorrect 64 ms 940 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 940 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 688 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 1108 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 940 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -