Submission #1218954

#TimeUsernameProblemLanguageResultExecution timeMemory
1218954im2xtreme가장 긴 여행 (IOI23_longesttrip)C++20
Compilation error
0 ms0 KiB
#include <vector> #include "longesttrip.h" using namespace std; vector<bool> visited; vector<int> current_path, best_path; void dfs(int u, const vector<vector<int>>& adj) { 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, adj); } } visited[u] = false; current_path.pop_back(); } int* longest_trip(int N, int D) { vector<vector<int>> adj(N); for (int current = 0; current < N; current++) { for (int i = current + 1; i < N; i++) { if (are_connected({current}, {i})) { adj[current].push_back(i); adj[i].push_back(current); } } } visited = vector<bool>(N, false); best_path.clear(); for (int i = 0; i < N; i++) { current_path.clear(); dfs(i, adj); } 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)

longesttrip.cpp:26:6: error: ambiguating new declaration of 'int* longest_trip(int, int)'
   26 | int* longest_trip(int N, int D) {
      |      ^~~~~~~~~~~~
In file included from longesttrip.cpp:2:
longesttrip.h:3:18: note: old declaration 'std::vector<int> longest_trip(int, int)'
    3 | std::vector<int> longest_trip(int N, int D);
      |                  ^~~~~~~~~~~~