Submission #1314343

#TimeUsernameProblemLanguageResultExecution timeMemory
1314343CyanberryMigrations (IOI25_migrations)C++20
30 / 100
28 ms480 KiB
#include "migrations.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> depth(10000, 0);
int maxi = 0;
int curr = 0;
int threshold = 10000 - 9;

int left4(int d) {
	return (1<<(2*d));
}

int send_message(int N, int i, int Pi) {
	if (i == 1) {
		depth.assign(N, 0);
		threshold = N - 9;
	}
	depth[i] = depth[Pi] + 1;
	if (depth[i] > maxi) {
		maxi = depth[i];
		if (i >= threshold) {
			curr = 0;
			return 4;
		} else {
			curr = i;
		}
	}
	if (i >= threshold) {
		int qit = N - i - 1;
		int v = 0, l = left4(qit);
		while (curr >= l) {
			++v;
			curr -= l;
		}
		return v;
	}
	return 0;
}

std::pair<int, int> longest_path(std::vector<int> S) {
	int ret = 0, overrule = 0;
	for (int i = max((int)S.size() - 9, 0); i < S.size(); ++i) {
		ret = ret<<2;
		ret += S[i];
		if (S[i] == 4) overrule = i;
	}
	return {0, overrule == 0 ? ret : overrule};
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...