Submission #1303856

#TimeUsernameProblemLanguageResultExecution timeMemory
1303856123123123이주 (IOI25_migrations)C++20
30 / 100
28 ms452 KiB
#include <bits/stdc++.h>
using namespace std;
int p[200005], L = 0;
string s = "";
int send_message(int N, int i, int Pi)
{
    int Lf;
    
    p[i] = p[Pi] + 1;
    
    if(p[i] > p[L])
    {
        L = i;
    }
    
    if(i == 9992)
    {
        Lf = L;
        
        if(Lf == 0) s = "0";
        else
        {
            while(Lf > 0)
            {
                s += char((Lf % 4) + '0');
                Lf /= 4;
            }
        }
        
          
        while(s.length() != 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> S)
{
    pair <int, int> ans = {0, 0};
    int i, v = 1, ch = 0;
    
    for(i = 9993; i <= 9999; i++)
    {
        if(S[i] == 4)
        {
            ans.second = i;
            ch = 1;
        }
        else if(ch == 0)
        {
            ans.second += v * S[i];
        }
        
        v *= 4;
    }
    
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...