Submission #1069576

#TimeUsernameProblemLanguageResultExecution timeMemory
1069576Faisal_SaqibLongest Trip (IOI23_longesttrip)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; bool are_connected(std::vector<int> A, std::vector<int> B); std::vector<int> longest_trip(int n, int D) { if(D==3) { vector<int> ans; for(int i=0;i<n;i++) ans.push_back(i); return ans; } else if(D==2) { vector<int> ans; for(int i=n-1;i>0;i--) ans.pb(i); ll s=0; vll order={0}; while(ans.size()>1) { ll f1=ans.back(); ans.pop_back(); ll f2=ans.back(); ans.pop_back(); bool r1=are_connected({s},{f1}); bool r2=are_connected({s},{f2}); bool r3=are_connected({f1},{f2}); if(r1 and r3) { order.pb(f1); order.pb(f2); } else if(r2 and r3) { order.pb(f2); order.pb(f1); } s=order.back(); } if(ans.size()>0) { ll l=ans.back(); bool r1=are_connected({s},{l}); if(r1) order.pb(l); } return order; } }

Compilation message (stderr)

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:17:8: error: 'class std::vector<int>' has no member named 'pb'
   17 |    ans.pb(i);
      |        ^~
longesttrip.cpp:18:3: error: 'll' was not declared in this scope
   18 |   ll s=0;
      |   ^~
longesttrip.cpp:19:3: error: 'vll' was not declared in this scope
   19 |   vll order={0};
      |   ^~~
longesttrip.cpp:22:6: error: expected ';' before 'f1'
   22 |    ll f1=ans.back();
      |      ^~~
      |      ;
longesttrip.cpp:24:6: error: expected ';' before 'f2'
   24 |    ll f2=ans.back();
      |      ^~~
      |      ;
longesttrip.cpp:26:27: error: 's' was not declared in this scope
   26 |    bool r1=are_connected({s},{f1});
      |                           ^
longesttrip.cpp:26:31: error: 'f1' was not declared in this scope; did you mean 'r1'?
   26 |    bool r1=are_connected({s},{f1});
      |                               ^~
      |                               r1
longesttrip.cpp:26:34: error: could not convert '{<expression error>}' from '<brace-enclosed initializer list>' to 'std::vector<int>'
   26 |    bool r1=are_connected({s},{f1});
      |                                  ^
      |                                  |
      |                                  <brace-enclosed initializer list>
longesttrip.cpp:27:31: error: 'f2' was not declared in this scope; did you mean 'r2'?
   27 |    bool r2=are_connected({s},{f2});
      |                               ^~
      |                               r2
longesttrip.cpp:27:34: error: could not convert '{s}' from '<brace-enclosed initializer list>' to 'std::vector<int>'
   27 |    bool r2=are_connected({s},{f2});
      |                                  ^
      |                                  |
      |                                  <brace-enclosed initializer list>
longesttrip.cpp:28:35: error: could not convert '{f1}' from '<brace-enclosed initializer list>' to 'std::vector<int>'
   28 |    bool r3=are_connected({f1},{f2});
      |                                   ^
      |                                   |
      |                                   <brace-enclosed initializer list>
longesttrip.cpp:31:5: error: 'order' was not declared in this scope
   31 |     order.pb(f1);
      |     ^~~~~
longesttrip.cpp:36:5: error: 'order' was not declared in this scope
   36 |     order.pb(f2);
      |     ^~~~~
longesttrip.cpp:39:6: error: 'order' was not declared in this scope
   39 |    s=order.back();
      |      ^~~~~
longesttrip.cpp:43:6: error: expected ';' before 'l'
   43 |    ll l=ans.back();
      |      ^~
      |      ;
longesttrip.cpp:44:27: error: 's' was not declared in this scope
   44 |    bool r1=are_connected({s},{l});
      |                           ^
longesttrip.cpp:44:31: error: 'l' was not declared in this scope
   44 |    bool r1=are_connected({s},{l});
      |                               ^
longesttrip.cpp:44:33: error: could not convert '{<expression error>}' from '<brace-enclosed initializer list>' to 'std::vector<int>'
   44 |    bool r1=are_connected({s},{l});
      |                                 ^
      |                                 |
      |                                 <brace-enclosed initializer list>
longesttrip.cpp:46:5: error: 'order' was not declared in this scope
   46 |     order.pb(l);
      |     ^~~~~
longesttrip.cpp:48:10: error: 'order' was not declared in this scope
   48 |   return order;
      |          ^~~~~