답안 #483903

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
483903 2021-11-01T10:07:35 Z evenvalue 악어의 지하 도시 (IOI11_crocodile) C++17
컴파일 오류
0 ms 0 KB
#include "crocodile.h"
#include <vector>
using namespace std;

struct edge {
  int x;
  int y;
  int w;
};

class solution {
  const int kInf = 1e9 + 10;
  const int n;
  const int m;
  const vector<edge> edges;
  const int k;
  const vector<int> end;
  vector<vector<pair<int, int>>> g;
  vector<int> dp;

  int dfs(const int x, const int p) {
    if (dp[x] == 0) return 0;
    int mn = kInf, mn2 = kInf;
    for (const auto &[y, w] : g[x]) {
      if (y == p) continue;
      const int cur = dfs(y, x) + w;
      if (cur < mn) {
        mn2 = mn;
        mn = cur;
      } else {
        mn2 = min(mn2, cur);
      }
    }
    return (dp[x] = mn2);
  }

public:
  explicit solution(const int n, const vector<edge> &edges, const vector<int> &end) : n(n), m(edges.size()), edges(edges), k(end.size()), end(end), g(n), dp(n, kInf) {
    for (const auto &[x, y, w] : edges) {
      g[x].emplace_back(y, w);
      g[y].emplace_back(x, w);
    }
    for (const int x : end) dp[x] = 0;
  }

  int solve() {
    return dfs(0, -1);
  }
};

int travel_plan(const int N, const int M, const int Edges[][2], const int Cost[], const int K, const int P[]) {
  vector<edge> edges(M);
  for (int i = 0; i < M; i++) {
    edges[i].x = Edges[i][0];
    edges[i].y = Edges[i][1];
    edges[i].w = Cost[i];
  }
  vector<int> end(K);
  for (int i = 0; i < K; i++) {
    end[i] = P[i];
  }
  solution s(N, edges, end);
  return s.solve();
}

Compilation message

/usr/bin/ld: /tmp/ccHM06qX.o: in function `main':
grader.cpp:(.text.startup+0x36): undefined reference to `travel_plan(int, int, int (*) [2], int*, int, int*)'
collect2: error: ld returned 1 exit status