#include "migrations.h"
#include <iostream>
#include <cmath>
using namespace std;
int dist[10000];
int maxd,was4,u_max;
int send_message(int N, int u, int pu) {
int ans;
dist[u]=dist[pu]+1;
if (u<N-7) {
if (dist[u]>maxd) maxd=dist[u], u_max=u;
ans=0;
}
if (u==N-7){
if (dist[u]>maxd) {
maxd=dist[u]; was4=1;
ans=4;
} else {
ans=u_max%4;
u_max=u_max/4;
}
}
if (u>N-7) {
if (dist[u]>maxd) {
maxd=dist[u]; was4=1;
ans=4;
} else {
if (was4) ans=0;
else ans=u_max%4, u_max=u_max/4;
}
}
return ans;
}
std::pair<int, int> longest_path(std::vector<int> S) {
pair <int,int> ans={0,0};
int n=S.size();
int x=0;
for (int i=n-7;i<n;i++){
if (S[i]==4) x=i;
}
if (x==0) {
int h=1;
for (int i=n-7;i<n;i++){
x=x+S[i]*h;
h=h*4;
}
}
ans.second=x;
return ans;
}
/*
10
0 1 2 2 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... |