# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
839807 | 2023-08-30T16:57:01 Z | AdamGS | Longest Trip (IOI23_longesttrip) | C++17 | 0 ms | 0 KB |
#include "longesttrip.h" #include<bits/stdc++.h> using namespace std; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() vector<int>longest_trip(int n, int d) { vector<int>A, B; A.pb(0); for(int i=1; i<n; ++i) { vector<int>X, Y; X.pb(A.back()); Y.pb(i); if(are_connected(X, Y)) A.pb(i); else B.pb(i); X.clear(); Y.clear(); X.pb(A.back()); Y.pb(B.back()); if(are_connected(X, Y)) while(Y.size()>0) { X.pb(Y.back()); Y.pop_back(); } } if(Y.size()>X.size()) swap(X, Y); return X; }