Submission #839807

#TimeUsernameProblemLanguageResultExecution timeMemory
839807AdamGSLongest Trip (IOI23_longesttrip)C++17
Compilation error
0 ms0 KiB
#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; }

Compilation message (stderr)

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:27:6: error: 'Y' was not declared in this scope
   27 |   if(Y.size()>X.size()) swap(X, Y);
      |      ^
longesttrip.cpp:27:15: error: 'X' was not declared in this scope
   27 |   if(Y.size()>X.size()) swap(X, Y);
      |               ^
longesttrip.cpp:28:10: error: 'X' was not declared in this scope
   28 |   return X;
      |          ^