# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
840515 | jonathanirvings | Longest Trip (IOI23_longesttrip) | C++17 | 477 ms | 592 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;
vector<int> longest_trip(int N, int D)
{
vector<int> path = {0};
vector<bool> inside(N, false);
inside[0] = true;
vector<vector<int>> memo(N, vector<int>(N, -1));
auto is_connected = [&] (int x, int y) {
if (memo[x][y] >= 0) {
return memo[x][y];
}
memo[x][y] = memo[y][x] = are_connected({x}, {y});
return memo[x][y];
};
while (true) {
if (path.size() == N) {
return path;
}
bool found = false;
for (int i = 0; i < N && !found; ++i) {
if (!inside[i]) {
if (is_connected(path[0], i)) {
path.insert(path.begin(), i);
found = true;
inside[i] = true;
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... |