# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
960598 | TAhmed33 | Longest Trip (IOI23_longesttrip) | C++17 | 90 ms | 2156 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;
int cnt;
vector <int> tree[256];
bool vis[256];
vector <int> x;
int p[256];
set <int> unvis;
void dfs (int pos) {
vis[pos] = 1; x.push_back(pos); unvis.erase(pos);
while (!unvis.empty()) {
vector <int> t; for (auto i : unvis) t.push_back(i);
if (!are_connected({pos}, t)) break;
int l = 0, r = (int)t.size() - 1, ans = -1;
while (l <= r) {
int mid = (l + r) / 2;
vector <int> g;
for (int i = 0; i <= mid; i++) g.push_back(t[i]);
cnt++; assert(cnt <= 3000);
if (are_connected({pos}, g)) {
r = mid - 1; ans = mid;
} else {
l = mid + 1;
}
}
if (ans == -1) break;
tree[pos].push_back(t[ans]);
p[t[ans]] = pos;
dfs(t[ans]);
# | 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... |