#include "migrations.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 10009;
#define st first
#define nd second
typedef long long ll;
typedef pair<int,int> pii;
int dis[maxn];
int aktn = 0;
int aktb = 0;
int send_message(int N, int i, int Pi)
{
if(i == 1)
{
aktb = 0;
aktn = 0;
for(int j = 0; j < N; j++)dis[i] = 0;
}
dis[i] = dis[Pi]+1;
if(i < N-30)return 0;
if((N-30 <= 0 && i == 1) || i == N-30)
{
int maxi = 0;
for(int j = 0 ; j <= i-1 ; j++)
{
if(dis[j] >= maxi)
{
maxi = dis[j];
aktn = j;
}
}
if(dis[i] > dis[aktn])
{
aktb = 14;
return 1;
}
if(aktb == 14)return 0;
if((aktn&(1<<aktb)))
{
aktb++;
return 3;
}
aktb++;
return 2;
}
else
{
if(dis[i] > dis[aktn])
{
aktb = 14;
return 1;
}
if(aktb == 14)return 0;
if((aktn&(1<<aktb)))
{
aktb++;
return 3;
}
aktb++;
return 2;
}
}
std::pair<int, int> longest_path(std::vector<int> S)
{
int f = min(1,(int)(S.size())-30);
int aktp = 0;
int b = 0;
for(int i = f ; i < S.size() ; i++)
{
if(S[i] == 1)
{
aktp = i;
}
else if(S[i] == 0)continue;
else
{
aktp += ((1<<b)*(S[i]-2));
b++;
}
}
return {0,aktp};
}
/*
35
0 1 2 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |