답안 #504777

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
504777 2022-01-10T08:38:42 Z daongocha Speedrun (RMI21_speedrun) C++14
0 / 100
1 ms 384 KB
#include "speedrun.h"

#include <bits/stdc++.h>

#define fileopen(a, b) freopen(((std::string)a + ".inp").c_str(), "r", stdin); freopen(((std::string)b + ".out").c_str(), "w", stdout);
#define fileopen1(a) freopen(((std::string)a + ".inp").c_str(), "r", stdin); freopen(((std::string)a + ".out").c_str(), "w", stdout);
 
using namespace std;

const int MAXN = 1005;
vector<int> path[MAXN];
vector<int> order;
int parent[MAXN];

void dfs(int u, int pre = 0) {
	order.push_back(u);
	parent[u] = pre;
	for (int v: path[u])
		if (v != pre) dfs(v, u);
}

void assignHints(int sub, int n, int A[], int B[]) {
	for (int i = 0; i + 1 < n; i++) {
		int u = A[i], v = B[i];
		path[u].push_back(v);
		path[v].push_back(u);
	}
	
	dfs(1);

	setHintLen(20);
	for (int i = n - 2; i >= 0; i--) {
		int u = order[i], v = order[i + 1];
		for (int j = 1; j <= 10; j++)
			setHint(u, j - 1, (v >> (j - 1) & 1));

		for (int j = 11; j <= 20; j++)
			setHint(u, j - 1, (parent[u] >> (j - 11) & 1));
	}
}

int nxt[MAXN], par[MAXN];
bool passed[MAXN];

void solve(int u, int go) {
	if (!passed[u]) {
		for (int j = 0; j < 10; j++)
			nxt[u] |= (getHint(j) << j);

		for (int j = 0; j < 10; j++) 
			par[u] |= (getHint(j + 10) << j);

		if (!nxt[u]) return;
		
		go = nxt[u];
	}

	if (!goTo(go)) goTo(par[u]), solve(par[u], go);
	else solve(go, 0);
}

void speedrun(int sub, int n, int start) {
	solve(start, 0);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 328 KB Invalid node index for setHint
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 328 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 328 KB Invalid node index for setHint
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Invalid node index for setHint
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 328 KB Invalid node index for setHint
2 Halted 0 ms 0 KB -