#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> longest_trip(int n, int d){
vector <int> a, b;
a.push_back(0);
// int x = 1;
// while(x < n && are_connected({0}, {x})){
// a.push_back(x);
// x++;
// }
// if(x == n) return a;
// b.push_back(x);
for(int i = 1; i < n; i++){
if(are_connected({a.back()}, {i})) a.push_back(i);
else b.push_back(i);
if(!b.empty() && are_connected({a.back()}, {b.back()})){
while(!b.empty()){
a.push_back(b.back());
b.pop_back();
}
}
}
if(a.size() > b.size()) return a;
return b;
}
# | 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... |