# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
841296 | 2023-09-01T12:59:54 Z | Stavab | Longest Trip (IOI23_longesttrip) | C++17 | 0 ms | 0 KB |
#include "longesttrip.h" #include <algorithm> std::vector<int> longest_trip(int N, int D) { std::vector<int> solution; int node = 0; while(node < N - 1) { solution.push_back(node); if(are_connected({node}, {node + 1})) { solution.push_back(node + 1); node++; } else if(node != N - 2) { solution.push_back(node + 2); solution.push_back(node + 1); node += 2; } else { reverse(solution.begin(), solution.end()); solution.push_beck(N - 1); node++; } } return solution; }