제출 #1255053

#제출 시각아이디문제언어결과실행 시간메모리
1255053tosivanmak이주 (IOI25_migrations)C++20
0 / 100
28 ms456 KiB
#include "migrations.h"
#include<bits/stdc++.h>
using namespace std;
#define ll int

ll dep[10005];
ll maxdep=0; ll nd;
vector<ll>bt;
// N-i<=19
// 10000 9981
// 9981 to 9999 19 information
int send_message(int N, int i, int Pi) {
  dep[0]=0;
  dep[i]=dep[Pi]+1;
  if(dep[i]>maxdep){
      maxdep=dep[i]; nd=i;
  }
  if(N-i>=20)return 0;
  if(N-i==19){
      if(nd==i)return 3;
      for(int i=18;i>=0;i--){
          if(nd&(1LL<<i))bt.push_back(2);
          else bt.push_back(1);
      }
    //   0 18
      return bt[N-i-1];
  }
  else{
      if(nd==i)return 3;
      else if(N-nd<=19)return 0;
      return bt[N-i-1];
  }
}

std::pair<int, int> longest_path(std::vector<int> S) {
    for(int i=9999;i>=1;i--){
        if(S[i]==3){
            return {0,S[i]};
        }
    }
    ll tk=0;
    for(int i=10000-19;i<=9999;i++){
        ll ans=(1LL<<(10000-i-1))*(S[i]-1);
        tk+=ans;
    }
    return {0,tk};
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...