답안 #869262

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
869262 2023-11-03T22:06:57 Z MinaRagy06 Speedrun (RMI21_speedrun) C++17
0 / 100
41 ms 880 KB
#include <bits/stdc++.h>
#ifdef MINA
#include "grader.cpp"
#endif
#include "speedrun.h"
using namespace std;
typedef int64_t ll;

bool get(int vals[3]) {
	if (~vals[0]) return 1;
	for (int j = 0; j < 3; j++) {
		vals[j] = 0;
		for (int b = 0; b < 10; b++) {
			if (getHint(10 * j + b + 1)) {
				vals[j] |= 1 << b;
			}
		}
	}
	return 1;
}
void assign(int i, int vals[3]) {
	for (int j = 0; j < 3; j++) {
		for (int b = 0; b < 10; b++) {
			if ((vals[j] >> b) & 1) {
				setHint(i, 10 * j + b + 1, 1);
			}
		}
	}
}
void dfs(int i, int par, int nxt, vector<int> adj[], int vals[][3]) {
	vals[i][0] = 0;
	vals[i][1] = nxt;
	vals[i][2] = par;
	for (int j = 0; j < (int) adj[i].size(); j++) {
		if (adj[i][j] == par) continue;
		vals[i][0] = adj[i][j];
		int newpar = i;
		int newnxt = 0;
		for (int k = j + 1; k < (int) adj[i].size(); k++) {
			if (adj[i][k] == par) continue;
			newnxt = adj[i][k];
			break;
		}
		dfs(adj[i][j], newpar, newnxt, adj, vals);
	}
}
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(30);
	int vals[n + 1][3];
	memset(vals, -1, sizeof vals);
	dfs(1, 0, 0, adj, vals);
	for (int i = 1; i <= n; i++) {
		assign(i, vals[i]);
	}
}
void dfs(int i, int vals[][3]) {
	while (1) {
		get(vals[i]);
		if (vals[i][0]) {
			goTo(vals[i][0]);
			dfs(vals[i][0], vals);
		}
		if (vals[i][1]) {
			goTo(vals[i][2]);
			goTo(vals[i][1]);
			i = vals[i][1];
		} else {
			break;
		}
	}
	get(vals[i]);
	if (vals[i][2]) goTo(vals[i][2]);
}
void speedrun(int subtask, int n, int start) {
	int vals[n + 1][3];
	memset(vals, -1, sizeof vals);
	int cur = start;
	while (get(vals[cur]) && vals[cur][2]) {
		cur = vals[cur][2];
		goTo(cur);
	}
	assert(cur == 1);
	dfs(cur, vals);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 880 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 340 KB The length is too large
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB The length is too large
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 41 ms 876 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 872 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -