# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
846937 | arbuzick | Longest Trip (IOI23_longesttrip) | C++17 | 16 ms | 856 KiB |
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) {
mt19937 rnd(57);
vector<int> ord(n);
iota(ord.begin(), ord.end(), 0);
shuffle(ord.begin(), ord.end(), rnd);
vector<int> ans1, ans2;
bool disconnected = false;
for (int i = 0; i < n; ++i) {
if (ans1.empty() || are_connected({ans1.back()}, {ord[i]})) {
ans1.push_back(ord[i]);
disconnected = false;
} else if (disconnected) {
ans2.push_back(ord[i]);
} else if (ans2.empty() || are_connected({ans2.back()}, {ord[i]})) {
ans2.push_back(ord[i]);
disconnected = true;
} else {
if (i == n - 1) {
reverse(ans2.begin(), ans2.end());
for (auto vl : ans2) {
ans1.push_back(vl);
}
ans2 = {ord[i]};
} else {
# | 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... |