#include "migrations.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define sp <<" "<<
#define endl "\n"
const int N = 10000;
const int ref[7] = {9999, 9998, 9997, 9996, 9995, 9994, 9993}; // for ref ig
const int pw4[7] = {1, 4, 16, 64, 256, 1024, 4096};
vector<int> dep, par;
bool flip = false;
int send_message(int _N, int i, int Pi) {
if (i == 1) {
dep.assign(N, 0);
par.assign(N, 0);
}
par[i] = Pi;
dep[i] = dep[par[i]] + 1;
int res = 0;
for (int k = 0; k <= 6; k++) {
if (i == ::ref[k]) {
int best = -1, ind = -1;
for (int j = 0; j < N; j++) {
if (dep[j] > best) {
best = dep[j];
ind = j;
}
}
if (ind == i) {
res = 4;
} else {
for (int j = 6; j > k; j--) {
ind %= pw4[j];
}
res = ind / pw4[k];
}
}
}
return res;
}
pair<int, int> longest_path(vector<int> S) {
int v = -1;
for (int k = 0; k <= 6; k++) {
if (S[::ref[k]] == 4) {
v = ::ref[k];
break;
}
}
if (v == -1) {
int res = 0;
for (int k = 0; k <= 6; k++) {
res += pw4[k] * S[::ref[k]];
}
v = res;
}
return {0, v};
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |