Submission #1218957

#TimeUsernameProblemLanguageResultExecution timeMemory
1218957im2xtremeLongest Trip (IOI23_longesttrip)C++20
0 / 100
1085 ms724 KiB
#include <vector> #include "longesttrip.h" using namespace std; 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(); } vector<int> longest_trip(int N, int D) { adj = vector<vector<int>>(N); visited = vector<bool>(N, false); best_path.clear(); for (int u = 0; u < N; ++u) { for (int v = u + 1; v < N; ++v) { vector<int> A = {u}, B = {v}; if (are_connected(A, B)) { adj[u].push_back(v); adj[v].push_back(u); } } } for (int i = 0; i < N; ++i) { current_path.clear(); dfs(i); } return best_path; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...