# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1161291 | The_Samurai | Longest Trip (IOI23_longesttrip) | C++20 | 449 ms | 832 KiB |
#include "longesttrip.h"
#include "bits/stdc++.h"
using namespace std;
mt19937 rng(time(0));
int rand(int l, int r) {
int x = rng(); x = abs(x);
return x % (r - l + 1) + l;
}
vector<int> longest_trip(int n, int d) {
vector can(n, vector(n, false));
vector<vector<int>> g(n);
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
bool p = are_connected({i}, {j});
if (!p) continue;
can[i][j] = can[j][i] = p;
g[i].emplace_back(j);
g[j].emplace_back(i);
// if (can[i][j]) cout << '\t' << i << ' ' << j << endl;
}
}
vector<bool> vis(n);
vector<int> way, ans;
auto dfs = [&](auto &dfs, int u) -> void {
way.emplace_back(u);
if (ans.size() < way.size()) ans = way;
vis[u] = true;
# | 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... |