# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
878559 | thinknoexit | Longest Trip (IOI23_longesttrip) | C++17 | 0 ms | 0 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 <bits/stdc++.h>
#include "longesttrip.h"
using namespace std;
using ll = long long;
int n, d;
bool adj[256][256];
vector<int> longest_trip(int N, int D) {
n = N;
d = D;
memset(adj, 0, sizeof adj);
for (int i = 0;i < n;i++) {
for (int j = i + 1;j < n;j++) {
adj[i][j] = adj[j][i] = are_connected({ i }, { j });
}
}
queue<int> q;
for (int i = 1;i < n;i++) {
q.push(i);
}
deque<int> ans;
ans.push_back(0);
while (!q.empty()) {
if (adj[ans.back()][q.front()]) {
ans.push_back(q.front());
q.pop();
}
else {
ans.push_front(q.front());
q.pop();
}
}
return ans;
}