# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
841555 | 2023-09-01T16:49:26 Z | Stavab | Longest Trip (IOI23_longesttrip) | C++17 | 23 ms | 352 KB |
#include "longesttrip.h" #include <algorithm> std::vector<std::vector<int>> graph; std::vector<int> solution, visited, temp; void dfs(int n) { if(visited[n]) return; visited[n] = 1; temp.push_back(n); for(int i = 0; i < graph[n].size(); i++) dfs(graph[n][i]); if(temp.size() > solution.size()) solution = temp; temp.pop_back(); } std::vector<int> longest_trip(int N, int D) { graph.assign(N, std::vector<int>()); for(int i = 0; i < N; i++) { for(int j = i + 1; j < N; j++) { if(are_connected({i}, {j})) { graph[i].push_back(j); graph[j].push_back(i); } } } visited.assign(N, 0); for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) visited[j] = 0; dfs(i); } return solution; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | Incorrect |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 352 KB | Output is correct |
2 | Incorrect | 22 ms | 344 KB | Incorrect |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 344 KB | Output is correct |
2 | Incorrect | 21 ms | 344 KB | Incorrect |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 344 KB | Output is correct |
2 | Incorrect | 23 ms | 344 KB | Incorrect |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 344 KB | Output is correct |
2 | Incorrect | 20 ms | 344 KB | Incorrect |
3 | Halted | 0 ms | 0 KB | - |