Submission #578774

#TimeUsernameProblemLanguageResultExecution timeMemory
578774thiago_bastosCarnival Tickets (IOI20_tickets)C++17
Compilation error
0 ms0 KiB
#include "tickets.h" #include <vector> #include <algorithm> #include <utility> long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); long long prize = 0; auto answer = std :: vector<std :: vector<int>>(n, std :: vector<int>(m, -1)); std :: vector<std :: pair<int, int>> a; std :: vector<int> l(n, m), r(n, 0), lo(n, 0), hi(n, m - 1); for(int i = 0; i < n; ++i) for(int v : x[i]) a.emplace_back(v, i); std :: sort(a.begin(), a.end()); for(int i = size(a) / 2; i < (int)size(a); ++i) { auto [v, k] = a[i]; ++r[k], --l[k]; } for(int j = 0; j < k; ++j) { int L = 0, R = 0; for(int i = 0; i < n; ++i) { if(l[i] && !r[i]) { ++L, --l[i]; prize -= x[i][lo[i]]; answer[i][lo[i]++] = j; } else if(!l[i] && r[i]) { ++R, --r[i]; prize += x[i][hi[i]]; answer[i][hi[i]--] = j; } } vector<std :: pair<int, int>> a; for(int i = 0; i < n; ++i) { if(l[i] && r[i]) { prize += x[i][hi[i]]; answer[i][hi[i]] = j; a.emplace_back(-x[i][lo[i]] - x[i][hi[i]], i); --hi[i], --r[i]; } } std :: sort(a.rbegin(), a.rend()); for(int i = 0; i < n / 2 - L; ++i) { auto [v, k] = a[i]; prize += v; answer[k][hi[k]++] = -1; answer[k][lo[k]++] = j; ++r[k], --l[k]; } } allocate_tickets(answer); return prize; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:42:3: error: 'vector' was not declared in this scope
   42 |   vector<std :: pair<int, int>> a;
      |   ^~~~~~
tickets.cpp:42:3: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from tickets.h:1,
                 from tickets.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from tickets.h:1,
                 from tickets.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
tickets.cpp:42:30: error: expected primary-expression before '>' token
   42 |   vector<std :: pair<int, int>> a;
      |                              ^~