| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1327741 | SpyrosAliv | Longest Trip (IOI23_longesttrip) | C++20 | 31 ms | 440 KiB |
#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;
int n;
std::vector<int> longest_trip(int N, int D)
{
n = N;
vector<int> path;
vector<bool> used(n, false);
path.push_back(0);
used[0] = true;
while (path.size() != n) {
int lst = path.back();
vector<int> cands;
for (int i = 0; i < n; i++) {
if (!used[i]) cands.push_back(i);
}
bool conn = are_connected({path.back()}, {cands});
if (!conn) {
if (cands.size() > path.size()) return cands;
return path;
}
int nxt = -1;
int lo = 0, hi = cands.size() - 1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
vector<int> qr;
for (int j = 0; j <= mid; j++) {
qr.push_back(cands[j]);
}
bool conn = are_connected({path.back()}, qr);
if (conn) {
nxt = cands.back();
hi = mid-1;
}
else lo = mid+1;
}
path.push_back(nxt);
used[nxt] = true;
}
return path;
}
| # | 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... | ||||
