# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
842486 | CodePlatina | 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 "longesttrip.h"
#include <iostream>
#include <algorithm>
#define pii pair<int, int>
#define ff first
#define ss second
using namespace std;
vector<int> longest_trip(int N, int d)
{
bool chc[N]{};
vector<pii> V;
for(int i = 0; i < N; ++i)
{
for(int j = i + 1; j < N; ++j)
{
if(!are_connected(vector<int>{i}, vector<int>{j}))
chc[i] = true, chc[j] = true, V.push_back({i, j});
}
}
vector<int> ret;
for(auto [x, y] : V) ret.push_back(x);
for(int i = 0; i < N; ++i) if(!chc[i]) ret.push_back(x);
for(auto [x, y] : V) ret.push_back(y);
return ret;
}