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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //mt19937_64 for ll
int rnd(int l, int r) {
return l + rng() % (r - l + 1);
}
vector<int> longest_trip(int n, int D) {
vector<int> v = {0};
vector<bool> vis(n, false); vis[0] = true;
while ((int)v.size() < n) {
vector<bool> vis2 = vis;
while (true) {
int x = rnd(1, n - 1);
while (!vis2[x]) x = rnd(1, n - 1);
if (are_connected({v.back()}, {x})) {
vis[x] = true;
v.push_back(x);
break;
}
vis2[x] = true;
}
}
return v;
}
# | 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... |