Submission #751912

#TimeUsernameProblemLanguageResultExecution timeMemory
751912kenansalloumThousands Islands (IOI22_islands)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <unordered_set> using namespace std; bool dfs(int curr, int prev, vector<vector<int>>& adjList, vector<int>& journey, unordered_set<int>& usedCanoes) { journey.push_back(curr); if (curr == 0 && journey.size() > 1) { return true; } for (int next : adjList[curr]) { if (next != prev && !usedCanoes.count(next)) { usedCanoes.insert(next); if (dfs(next, curr, adjList, journey, usedCanoes)) { return true; } usedCanoes.erase(next); } } journey.pop_back(); return false; } vector<int> find_journey(int N, int M, vector<int>& U, vector<int>& V) { vector<vector<int>> adjList(N); for (int i = 0; i < M; i++) { adjList[U[i]].push_back(i); adjList[V[i]].push_back(i); } vector<int> journey; unordered_set<int> usedCanoes; dfs(0, -1, adjList, journey, usedCanoes); if (journey.size() <= 2000000) { return journey; } else { return {}; } } int main() { int N, M; cin >> N >> M; vector<int> U(M), V(M); for (int i = 0; i < M; i++) { cin >> U[i] >> V[i]; } vector<int> result = find_journey(N, M, U, V); if (result.empty()) { cout << "false" << endl; } else { cout << "true" << endl; cout << result.size() << endl; for (int i : result) { cout << i << " "; } cout << endl; } return 0; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccKXue73.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccQqjev0.o:islands.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccKXue73.o: in function `main':
grader.cpp:(.text.startup+0x229): undefined reference to `find_journey(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status