#include <bits/stdc++.h>
using namespace std;
int p[200005], L = 0;
int send_message(int N, int i, int Pi)
{
int Lf;
string s;
p[i] = p[Pi] + 1;
if(p[i] > p[L])
{
L = i;
}
if(i == 9992)
{
s = "";
Lf = L;
if(Lf == 0) s = "0";
else
{
while(Lf > 0)
{
s += to_string(Lf %= 4);
Lf /= 4;
}
while(s.size() != 7)
{
s += "0";
}
}
}
else if(i > 9992)
{
if(L == i) return 4;
else return (int)(s[i - 9993] - '0');
}
return 0;
}
pair <int, int> longest_path(vector <int> a)
{
pair <int, int> ans = {0, 0};
int i, v = 1, ch = 0;
for(i = 9993; i <= 9999; i++)
{
if(a[i] == 4)
{
ans.second = i;
ch = 1;
}
else if(ch == 0)
{
ans.second += v * a[i];
}
v *= 4;
}
return ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |