Submission #1217885

#TimeUsernameProblemLanguageResultExecution timeMemory
1217885im2xtremeLongest Trip (IOI23_longesttrip)C++20
Compilation error
0 ms0 KiB
#include <vector> #include <algorithm> using namespace std; // Provided API extern bool are_connected(const vector<int>& A, const vector<int>& B); vector<vector<int>> adj; vector<bool> visited; vector<int> current_path, best_path; void dfs(int u) { visited[u] = true; current_path.push_back(u); if (current_path.size() > best_path.size()) { best_path = current_path; } for (int v : adj[u]) { if (!visited[v]) { dfs(v); } } visited[u] = false; current_path.pop_back(); } int* longest_trip(int N, int D) { adj = vector<vector<int>>(N); // Step 1: Discover edges using are_connected for (int i = 0; i < N; ++i) { for (int j = i + 1; j < N; ++j) { vector<int> A = {i}, B = {j}; if (are_connected(A, B)) { adj[i].push_back(j); adj[j].push_back(i); } } } // Step 2: Run DFS from all nodes visited = vector<bool>(N, false); best_path.clear(); for (int i = 0; i < N; ++i) { current_path.clear(); dfs(i); } // Step 3: Convert vector to static array int* result = new int[best_path.size()]; for (int i = 0; i < (int)best_path.size(); ++i) { result[i] = best_path[i]; } return result; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccRR7TMi.o: in function `longest_trip(int, int)':
longesttrip.cpp:(.text+0x45a): undefined reference to `are_connected(std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status