제출 #1287327

#제출 시각아이디문제언어결과실행 시간메모리
1287327kawhietMigrations (IOI25_migrations)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "migrations.h"
using namespace std;

vector<int> g[10001];
vector<int> d;
vector<bool> vis;

void dfs(int u) {
  vis[u] = 1;
  for (auto v : g[u]) {
    if (!vis[v]) {
      d[v] = d[u] + 1;
      dfs(v);
    }
  }
}

pair<int, int> get(int N) {
  d.assign(N, 0);
  vis.assign(N, false);
  dfs(0);
  int u = d.size() - 1 - (max_element(d.rbegin(), d.rend()) - d.rbegin());
  return {0, u};
}

int x = 0;

int send_message(int N, int i, int Pi) {
  g[i].push_back(Pi);
  g[Pi].push_back(i);
  if (i == N - 1) {
    auto [_, u] = get(N);
    return u - x;
  }
  if (N - i <= 50) {
    auto [_, u] = get(N);
    cerr << u - x << '\n';
    if (u - x >= 202) {
      x += 202;
      return 101;
    } else if (u - x >= 100) {
      x += 100;
      return 100;
    }else {
      int ret = u - x;
      x = u;
      return ret;
    }
  }
  return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccJx4ZoN.o: in function `main':
stub.cpp:(.text.startup+0x230): undefined reference to `longest_path(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status