# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844010 | 2023-09-04T21:54:00 Z | LucaIlie | Closing Time (IOI23_closing) | C++17 | 0 ms | 0 KB |
#include "longesttrip.h" #include <bits/stdc++.h> using namespace std; const int MAX_N = 256; int vis[MAX_N]; vector<pair<int, int>> pairs; vector<int> ans; vector<int> longest_trip( int n, int d ) { for ( int u = 0; u < n; u++ ) { for ( int v = u + 1; v < n; v++ ) { int x = are_connected( { u }, { v } ); if ( !x ) { pairs.push_back( { u, v } ); vis[u] = vis[v] = true; } } } for ( int i = 0; i < pairs.size(); i++ ) ans.push_back( pairs[i].first ); for ( int u = 0; u < n; u++ ) { if ( !vis[u] ) ans.push_back( u ); } if ( n == 2 && pairs.size() == 1 ) return ans; for ( int i = pairs.size() - 1; i >= 0; i-- ) ans.push_back( pairs[i].second ); return ans; }