Submission #1081293

#TimeUsernameProblemLanguageResultExecution timeMemory
1081293ArthuroWichLongest Trip (IOI23_longesttrip)C++17
0 / 100
3091 ms5712 KiB
#include "longesttrip.h" #include<bits/stdc++.h> using namespace std; int ans = 0; vector<int> ord; int vis[200005]; vector<int> adj[200005]; void dfs(int i, int d, vector<int> proc) { if (vis[i]) { return; } vis[i] = 1; proc.push_back(i); if (d > ans) { d = ans; ord = proc; } for (int j : adj[i]) { dfs(j, d+1, proc); } proc.pop_back(); vis[i] = 0; } vector<int> longest_trip(int n, int d) { for (int i = 0; i < n; i++) { adj[i].clear(); } for (int i = 0; i < n; i++) { for (int j = i+1; j < n; j++) { if (are_connected({i}, {j})) { adj[i].push_back(j); adj[j].push_back(i); } } } ans = 0; ord.clear(); for (int i = 0; i < n; i++) { dfs(i, 0, {}); } return ord; }
#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...