Submission #1069642

#TimeUsernameProblemLanguageResultExecution timeMemory
1069642MuhammadSaramLongest Trip (IOI23_longesttrip)C++17
15 / 100
886 ms596 KiB
#include <bits/stdc++.h> using namespace std; bool are_connected(vector<int> A, vector<int> B); vector<int> longest_trip(int n, int D) { bool con[n][n]={}; for (int i=1;i<n;i++) for (int j=i+1;j<n;j++) if (are_connected({i},{j})) con[i][j]=con[j][i]=1; vector<int> ans,lef; ans.push_back(0); for (int i=1;i<n;i++) lef.push_back(i); for (int ct=0;ct<n-2;ct++) { if (!are_connected({lef.back()},{ans.back()})) swap(lef[n-2-ct],lef[n-2-ct-1]); ans.push_back(lef.back()); lef.pop_back(); } if (!are_connected({lef.back()},{ans.back()})) swap(ans[n-2],ans[n-3]); ans.push_back(lef[0]); 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...