Submission #967508

#TimeUsernameProblemLanguageResultExecution timeMemory
967508Jarif_RahmanLongest Trip (IOI23_longesttrip)C++17
5 / 100
8 ms344 KiB
#include "longesttrip.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; vector<int> longest_trip(int n, int D){ vector<int> A = {0}, B = {}; for(int i = 1; i < n; i++){ if(B.empty()){ if(are_connected({A.back()}, {i})) A.push_back(i); else if(are_connected({A[0]}, {i})) A.insert(A.begin(), i); else B = {i}; } else{ if(are_connected({A.back()}, {i})) A.push_back(i); else if(are_connected({B.back()}, {i})) B.push_back(i); else{ A.insert(A.end(), B.begin(), B.end()); B.clear(); i--; } } if(A.size() < B.size()) swap(A, B); } return A; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...