Submission #1081062

#TimeUsernameProblemLanguageResultExecution timeMemory
1081062serifefedartarAkcija (COCI21_akcija)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0);cin.tie(0) typedef long long ll; #define f first #define s second #define LOGN 21 const ll MOD = 1e9 + 7; const ll MAXN = 2100; #define int long long vector<pair<int,int>> v; int sg[4*MAXN], lazy[4*MAXN]; void init(int k, int a, int b) { if (a == b) { sg[k] = a; lazy[k] = 0; return ; } init(2*k, a, (a+b)/2); init(2*k+1, (a+b)/2+1, b); sg[k] = min(sg[2*k], sg[2*k+1]); lazy[k] = 0; } void push(int k, int a, int b) { if (lazy[k]) { sg[k] += lazy[k]; if (a != b) { lazy[2*k] += lazy[k]; lazy[2*k+1] += lazy[k]; } lazy[k] = 0; } } void update(int k, int a, int b, int q_l, int q_r, int val) { push(k, a, b); if (b < q_l || a > q_r) return ; if (q_l <= a && b <= q_r) { lazy[k] += val; push(k, a, b); return ; } update(2*k, a, (a+b)/2, q_l, q_r, val); update(2*k+1, (a+b)/2+1, b, q_l, q_r, val); sg[k] = min(sg[2*k], sg[2*k+1]); } int query(int k, int a, int b, int q_l, int q_r) { if (b < q_l || a > q_r) return 1e9; push(k, a, b); if (q_l <= a && b <= q_r) return sg[k]; return min(query(2*k, a, (a+b)/2, q_l, q_r), query(2*k+1, (a+b)/2+1, b, q_l, q_r)); } struct Partition { int n = 2100; vector<int> ban, here; int cnt = 0, cost = 0; Partition(vector<int> &_ban) : ban(_ban) { n = ban.size(); cnt = cost = 0; init(1, 1, n); for (int i = 0; i < n; i++) { if (ban[i] != -1 && (ban[i] == 1 || query(1, 1, n, v[i].s, n) == 0)) continue; cnt++; cost += v[i].f; if (ban[i] != -1) here.push_back(i); update(1, 1, n, v[i].s, n, -1); } } }; bool operator <(Partition A, Partition B) { return make_pair(A.cnt, -A.cost) < make_pair(B.cnt, -B.cost); } signed main() { fast; int n, k; cin >> n >> k; v = vector<pair<int,int>>(n); for (int i = 0; i < n; i++) cin >> v[i].f >> v[i].s; sort(v.begin(), v.end()); priority_queue<Partition> pq; pq.push(vector<int>(n)); while (!pq.empty()) { Partition Q = pq.top(); pq.pop(); cout << Q.cnt << " " << Q.cost << "\n"; k--; if (k == 0) exit(0); vector<int> ban_here = Q.ban; for (auto u : Q.here) { ban_here[u] = 1; pq.push(Partition(ban_here)); ban_here[u] = -1; } } for (int i = 0; i < k; i++) cout << "0 0\n"; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:96:27: error: no matching function for call to 'push(std::vector<long long int>)'
   96 |     pq.push(vector<int>(n));
      |                           ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = Partition; _Sequence = std::vector<Partition, std::allocator<Partition> >; _Compare = std::less<Partition>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = Partition]' (near match)
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:7: note:   conversion of argument 1 would be ill-formed:
Main.cpp:96:13: error: invalid user-defined conversion from 'std::vector<long long int>' to 'const value_type&' {aka 'const Partition&'} [-fpermissive]
   96 |     pq.push(vector<int>(n));
      |             ^~~~~~~~~~~~~~
Main.cpp:65:5: note: candidate is: 'Partition::Partition(std::vector<long long int>&)' (near match)
   65 |     Partition(vector<int> &_ban) : ban(_ban) {
      |     ^~~~~~~~~
Main.cpp:65:5: note:   conversion of argument 1 would be ill-formed:
Main.cpp:96:13: error: cannot bind non-const lvalue reference of type 'std::vector<long long int>&' to an rvalue of type 'std::vector<long long int>'
   96 |     pq.push(vector<int>(n));
      |             ^~~~~~~~~~~~~~
Main.cpp:96:13: error: cannot bind non-const lvalue reference of type 'std::vector<long long int>&' to an rvalue of type 'std::vector<long long int>'
Main.cpp:65:28: note:   initializing argument 1 of 'Partition::Partition(std::vector<long long int>&)'
   65 |     Partition(vector<int> &_ban) : ban(_ban) {
      |               ~~~~~~~~~~~~~^~~~
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = Partition; _Sequence = std::vector<Partition, std::allocator<Partition> >; _Compare = std::less<Partition>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = Partition]' (near match)
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note:   conversion of argument 1 would be ill-formed:
Main.cpp:96:13: error: invalid user-defined conversion from 'std::vector<long long int>' to 'std::priority_queue<Partition>::value_type&&' {aka 'Partition&&'} [-fpermissive]
   96 |     pq.push(vector<int>(n));
      |             ^~~~~~~~~~~~~~
Main.cpp:65:5: note: candidate is: 'Partition::Partition(std::vector<long long int>&)' (near match)
   65 |     Partition(vector<int> &_ban) : ban(_ban) {
      |     ^~~~~~~~~
Main.cpp:65:5: note:   conversion of argument 1 would be ill-formed:
Main.cpp:96:13: error: cannot bind non-const lvalue reference of type 'std::vector<long long int>&' to an rvalue of type 'std::vector<long long int>'
   96 |     pq.push(vector<int>(n));
      |             ^~~~~~~~~~~~~~
Main.cpp:96:13: error: cannot bind non-const lvalue reference of type 'std::vector<long long int>&' to an rvalue of type 'std::vector<long long int>'
Main.cpp:65:28: note:   initializing argument 1 of 'Partition::Partition(std::vector<long long int>&)'
   65 |     Partition(vector<int> &_ban) : ban(_ban) {
      |               ~~~~~~~~~~~~~^~~~