# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1132698 | SpyrosAliv | Longest Trip (IOI23_longesttrip) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
bool are_connected(vector<int> a, vector<int> b);
vector<int> longest_trip(int n, int d) {
if (d == 3) {
vector<int> ans;
for (int i = 0; i < n; i++) ans.push_back(i);
return ans;
}
else if (d == 2) {
vector<int> ans;
ans.push_back(0);
for (int i = 0; i < n-1; i++) {
bool x = are_connected({i}, {i+1});
if (x) {
ans.push_back(i+1);
continue;
}
else {
ans.push_back(i+2);
ans.push_back(i+1);
i++;
}
}
}
return {};
}