#include <bits/stdc++.h>
#include "longesttrip.h"
using namespace std;
#define ll long long
#define pb push_back
vector<int> longest_trip(int n, int D)
{
vector<int>path;
if (are_connected({0},{1})){
if (are_connected({1},{2})){
path.pb(0);path.pb(1);path.pb(2);
}else{
path.pb(1);path.pb(0);path.pb(2);
}
}else{
path.pb(0);path.pb(2);path.pb(1);
}
for (int i=3;i<n;i++){
if (are_connected({path.back()},{i}))path.pb(i);
else{
vector<int>ans;
ans.pb(i);
ans.insert(ans.end(),path.begin(),path.end());
path=ans;
}
}
return path;
}
// signed main(){
// int n,d;
// cin>>n>>d;
// vector<int>ans=longest_trip(n,d);
// for (auto x:ans){
// cout<<x<<" ";
// }cout<<endl;
// }
| # | 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... |