Submission #1069684

#TimeUsernameProblemLanguageResultExecution timeMemory
1069684Muhammad_AneeqLongest Trip (IOI23_longesttrip)C++17
15 / 100
1070 ms592 KiB
#include <vector> #include <set> #include "longesttrip.h" using namespace std; int const MAXN=256; bool nei[MAXN][MAXN]={}; vector<int>ans; vector<int>cur; bool vis[MAXN]={}; int n; void dfs(int u) { vis[u]=1; cur.push_back(u); bool w=0; for (int i=0;i<n;i++) { if (nei[i][u]&&!vis[i]) dfs(i); } if (w==0) { if (cur.size()>ans.size()) ans=cur; } cur.pop_back(); } vector<int> longest_trip(int N, int D) { n=N; ans={}; cur={}; for (int i=0;i<N;i++) for (int j=0;j<N;j++) nei[i][j]=0; for (int i=0;i<N;i++) for (int j=i+1;j<N;j++) if (are_connected({i},{j})) nei[i][j]=nei[j][i]=1; for (int i=0;i<N;i++) { for (int j=0;j<N;j++) vis[j]=0; dfs(i); } return ans; }
#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...