Submission #1243141

#TimeUsernameProblemLanguageResultExecution timeMemory
1243141nvujicaLongest Trip (IOI23_longesttrip)C++20
Compilation error
0 ms0 KiB
#include "longesttrip.h" #include <bits/stdc++.h> using namespace std; const int dosta = 1e5; vector<int> longest_trip(int n, int d){ srand(time(0)); vecto<int> v; for(int i = 0; i < n; i++) v.push_back(i); for(int i = 0; i < dosta; i++){ int p1 = rand() % n; int p2 = rand() % n; if(p1 != p2) swap(v[p1], v[p2]); } vector <int> a, b; a.push_back(0); for(int i = 1; i < n; i++){ //if(rand() % 2) swap(a, b); if(are_connected({a.back()}, {v[i]})) a.push_back(v[i]); else if(b.empty() || are_connected({b.back()}, {v[i]})) b.push_back(v[i]); else { while(!b.empty()){ a.push_back(b.back()); b.pop_back(); } b.push_back(v[i]); } } if(a.size() < b.size()) swap(a, b); return a; }

Compilation message (stderr)

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:11:5: error: 'vecto' was not declared in this scope
   11 |     vecto<int> v;
      |     ^~~~~
longesttrip.cpp:11:11: error: expected primary-expression before 'int'
   11 |     vecto<int> v;
      |           ^~~
longesttrip.cpp:12:32: error: 'v' was not declared in this scope
   12 |     for(int i = 0; i < n; i++) v.push_back(i);
      |                                ^
longesttrip.cpp:18:27: error: 'v' was not declared in this scope
   18 |         if(p1 != p2) swap(v[p1], v[p2]);
      |                           ^
longesttrip.cpp:28:39: error: 'v' was not declared in this scope
   28 |         if(are_connected({a.back()}, {v[i]})) a.push_back(v[i]);
      |                                       ^
longesttrip.cpp:28:25: error: could not convert '{<expression error>}' from '<brace-enclosed initializer list>' to 'std::vector<int>'
   28 |         if(are_connected({a.back()}, {v[i]})) a.push_back(v[i]);
      |            ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
      |                         |
      |                         <brace-enclosed initializer list>
longesttrip.cpp:29:43: error: could not convert '{<expression error>}' from '<brace-enclosed initializer list>' to 'std::vector<int>'
   29 |         else if(b.empty() || are_connected({b.back()}, {v[i]})) b.push_back(v[i]);
      |                              ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
      |                                           |
      |                                           <brace-enclosed initializer list>