제출 #1352942

#제출 시각아이디문제언어결과실행 시간메모리
1352942d4n13l이주 (IOI25_migrations)C++20
큐에 대기중
0 ms0 KiB
#include "migrations.h"
#include <bits/stdc++.h>

using namespace std;

vector <int> dist;
int big = 0, id = 0;
bool problem = false;

int send_message(int n, int x, int Pi) {
    if (x==1) {
        dist=vector <int> (n+1);
        dist[0]=0;
    }
    dist[x]=dist[Pi]+1;
    if (dist[x]>big) {
        if (x>=n-10) {
            problem=true;
        }
        big=dist[x];
        id=x;
    }
    if (problem and x>=n-2) {
        int g = n-id;
        int cop = g;
        if (x==n-2) {
            return g%4;
        } else {
            int cop = g;
            cop>>=2;
            return cop%4;
        }
    } else if (!problem and x>=n-10) {
        int bit = x-(n-10);
        int cop = id;
        cop>>=(2*bit);
        return cop%4;
    } else {
        return 0;
    }
}

std::pair<int, int> longest_path(std::vector<int> s) {
    int n = s.size();
    if (s[n-1]!=0) {
        return {0, s[n-2]+4*s[n-1]};
    } else {
        int mul = 1;
        int ans = 0;
        for (int i = n-10; i < n-2; i++) {
            ans+=s[i]*mul;
            mul*=4;
        }
        return {0,ans};
    }
}