답안 #871568

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
871568 2023-11-11T06:01:08 Z TAhmed33 Speedrun (RMI21_speedrun) C++17
33 / 100
197 ms 1456 KB
#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);	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 1208 KB Output is correct
2 Correct 75 ms 956 KB Output is correct
3 Correct 94 ms 940 KB Output is correct
4 Correct 102 ms 1196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB The length is too large
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 596 KB The length is too large
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 688 KB Output is correct
2 Correct 106 ms 1216 KB Output is correct
3 Correct 197 ms 1348 KB Output is correct
4 Correct 81 ms 1452 KB Output is correct
5 Correct 95 ms 1456 KB Output is correct
6 Correct 62 ms 1212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB The length is too large
2 Halted 0 ms 0 KB -