#include <bits/stdc++.h>
using namespace std;
int d[10000];
int last = 0;
string s = "";
void f( int n ) {
if ( n == 0 ) {
s = "0";
return;
}
while ( n > 0 ) {
s += char( ( n % 4 ) + '0' );
n /= 4;
}
return;
}
int send_message ( int n, int i, int pi ) {
d[i] = d[pi] + 1;
if ( d[i] > d[last] ) {
last = i;
}
if ( i == 9992 ) {
f( last );
while ( s.length() != 7 ) {
s += "0";
}
} else if ( i > 9992 ) {
if ( last == i ) {
return 4;
}
return (int)(s[i - 9993]-'0');
}
return 0;
}
pair <int, int> longest_path ( vector <int> a ) {
pair <int, int> answer = {0, 0};
int k = 1;
bool b = false;
for ( int i = 9993; i <= 9999; i++ ) {
if ( a[i] == 4 ) {
answer.second = i;
b = true;
} else if ( b == false ) {
answer.second += a[i] * k;
}
k *= 4;
}
return answer;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |