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>
#include "longesttrip.h"
using namespace std;
vector<int> longest_trip(int n, int d)
{
vector<int> used(n, 0);
deque<int> dq;
used[0] = 1;
dq.push_back(0);
if (are_connected({0}, {1})) dq.push_back(1), used[1] = 1;
else dq.push_back(2), used[2] = 1;
for (int i = 0; i < n; i++)
{
if (used[i]) continue;
if (are_connected({dq.back()}, {i})) dq.push_back(i);
else dq.push_front(i);
used[i] = 1;
}
vector<int> res;
while (!dq.empty()) res.push_back(dq.front()), dq.pop_front();
return res;
}
# | 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... |