This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |