This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// In the name of Allah
#include <bits/stdc++.h>
#include "longesttrip.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define F first
#define S second
#define endl '\n'
#define sep ' '
#define pb push_back
#define Mp make_pair
#define all(x) (x).begin(),(x).end()
#define len(x) ((ll) (x).size())
const int maxn = 600 + 7;
int n, d;
vector<int> res, resx;
bool mark[maxn];
vector<int> longest_trip(int N, int D) {
n = N; d = D;
res.clear(); resx.clear();
fill(mark, mark + n, 0);
if (d >= 2) {
if (are_connected({0}, {1})) {
res.pb(0); mark[0] = 1;
res.pb(1); mark[1] = 1;
}
else {
res.pb(0); mark[0] = 1;
res.pb(2); mark[2] = 1;
}
for (int i = 0; i < n; i++) {
if (mark[i]) continue;
if (are_connected({i}, {res.back()})) res.pb(i);
else {
resx.clear(); swap(res, resx);
res.pb(i);
for (int x : resx) res.pb(x);
}
mark[i] = 1;
}
}
else {
}
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... |