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 "longesttrip.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
vector<int> longest_trip(int n, int D){
vector<int> A = {0}, B = {};
for(int i = 1; i < n; i++){
if(B.empty()){
if(are_connected({A.back()}, {i})) A.push_back(i);
else if(are_connected({A[0]}, {i})) A.insert(A.begin(), i);
else B = {i};
}
else{
if(are_connected({A.back()}, {i})) A.push_back(i);
else if(are_connected({B.back()}, {i})) B.push_back(i);
else{
A.insert(A.end(), B.begin(), B.end());
B.clear();
i--;
}
}
if(A.size() < B.size()) swap(A, B);
}
return A;
}
# | 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... |