제출 #871568

#제출 시각아이디문제언어결과실행 시간메모리
871568TAhmed33Speedrun (RMI21_speedrun)C++17
33 / 100
197 ms1456 KiB
#include <bits/stdc++.h>
#include "speedrun.h"
using namespace std;
const int m = 31;
vector <int> conv (int x) {
	vector <int> ret;
	for (int i = 9; i >= 0; i--) {
		ret.push_back((x >> i) & 1);
	}
	return ret;
}
void assignHints (int subtask, int n, int a[], int b[]) {
	vector <int> adj[n + 1];
	for (int i = 1; i < n; i++) {
		adj[a[i]].push_back(b[i]);
		adj[b[i]].push_back(a[i]);
	}
	setHintLen(316);
	for (int i = 1; i <= n; i++) {
		if (adj[i].size() > m) continue;
		setHint(i, 316, 1);
		for (int j = 0; j < (int)adj[i].size(); j++) {
			auto x = conv(adj[i][j]);
			for (int l = 10 * j + 1; l <= 10 * j + 10; l++) {
				setHint(i, l, x[l - 10 * j - 1]);
			}	
		}
	}
}
int n;
void dfs (int pos, int par) {
	if (getHint(316) == 1) {
		vector <int> adj;
		for (int j = 0; j <= 30; j++) {
			int x = 0;
			for (int l = 10 * j + 1; l <= 10 * j + 10; l++) {
				x *= 2; x += getHint(l);
			}
			if (x != 0 && x != par) {
				adj.push_back(x);
			}
		}
		for (auto i : adj) {
			goTo(i);
			dfs(i, pos);
			goTo(pos);
		}
		return;
	}
	for (int i = 1; i <= n; i++) {
		if (i == pos || i == par) continue;
		if (goTo(i)) {
			dfs(i, pos);
			goTo(pos);
		}
	}
}
void speedrun (int subtask, int N, int start) {
	n = N; dfs(start, -1);	
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...