#include "migrations.h"
#include <bits/stdc++.h>
int d[100001];
int ans;
int ansN;
int send_message(int N, int i, int Pi)
{
if (i == 1)
{
d[0] = 0;
ans = 0;
ansN = 0;
}
d[i] = d[Pi] + 1;
if (d[i] > ans)
{
ans = d[i];
ansN = i;
if(i > N-8) return 4;
}
if(i>N-8) {
int kk = ans%4;
ans = ans/4;
return kk;
}
return 0;
}
std::pair<int, int> longest_path(std::vector<int> S)
{
int n = S.size();
int aans = -1;
for (int i = 1; i < n; i++)
{
if (S[i] == 4)
{
aans = i;
}
}
if(aans != -1) return {0, aans};
aans = 0;
int c = 1;
for(int i = 1; i < n; i++) {
aans += S[i]*c;
c= c * 4;
}
return {0, aans};
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |