# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
858547 | ikura355 | Longest Trip (IOI23_longesttrip) | C++17 | 11 ms | 600 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 "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> longest_trip(int n, int density) {
if (density == 3) {
// Return list of 0 to N-1
vector<int> ans(n);
iota(ans.begin(), ans.end(), 0);
return ans;
} else if (density == 2) {
vector<int> nxt(n);
int pair;
for (int i = 1; i < n; i++)
if (are_connected({0}, {i})) pair = i;
int head = 0, tail = pair;
nxt[head] = pair;
for (int i = 0; i < n; i++) {
if (i == 0 || i == pair) continue;
if (are_connected({head}, {i})) {
nxt[i] = head;
head = i;
} else {
nxt[tail] = i;
tail = i;
}
}
vector<int> ans;
while (true) {
ans.push_back(head);
if (head == tail) break;
head = nxt[head];
}
return ans;
}
return {};
}
Compilation message (stderr)
# | 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... |