Submission #1311498

#TimeUsernameProblemLanguageResultExecution timeMemory
1311498thuhienneShopping Plans (CCO20_day2problem3)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define re exit(0); int n,m,k; vector <int> good[200009]; pair <int,int> lim[200009]; vector <ll> print; struct temptation { int type,pos; ll cost; const bool operator < (const temptation & other) const { return cost > other.cost; } }; void djt() { // 1. Sort m?i vector good[i] // 2. T?o vector ch?a c?p {good[i][1]-good[i][0], i} và sort theo hi?u s? // 3. PQ luu: {t?ng_hi?n_t?i, idx_trong_danh_sách_dã_sort, idx_ph?n_t?_trong_nhóm} priority_queue <temptation> pq; while(pq.size() && print.size() < k) { auto [val, i, j] = pq.top(); pq.pop(); print.push_back(val); // Tang ph?n t? trong nhóm hi?n t?i if (j + 1 < groups[i].size()) pq.push({val + groups[i][j+1] - groups[i][j], i, j + 1}); // Th? nhóm ti?p theo if (i + 1 < m) { // Nhánh m?i: Thêm ph?n t? th? 2 c?a nhóm ti?p theo pq.push({val + groups[i+1][1] - groups[i+1][0], i + 1, 1}); // Nhánh "d?i vai": B? ph?n t? th? 2 nhóm i, thay b?ng ph?n t? th? 2 nhóm i+1 if (j == 1) pq.push({val - (groups[i][1] - groups[i][0]) + (groups[i+1][1] - groups[i+1][0]), i + 1, 1}); } } } int main() { ios_base::sync_with_stdio(0);cin.tie(nullptr); cin >> n >> m >> k; for (int i = 1;i <= n;i++) { int a,c;cin >> a >> c; good[a].push_back(c); } for (int i = 1;i <= m;i++) cin >> lim[i].first >> lim[i].second; for (int i = 1;i <= m;i++) sort(good[i].begin(),good[i].end()); djt(); }

Compilation message (stderr)

Main.cpp: In function 'void djt()':
Main.cpp:34:17: error: 'groups' was not declared in this scope
   34 |     if (j + 1 < groups[i].size())
      |                 ^~~~~~
Main.cpp:35:16: error: no matching function for call to 'std::priority_queue<temptation>::push(<brace-enclosed initializer list>)'
   35 |         pq.push({val + groups[i][j+1] - groups[i][j], i, j + 1});
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:157,
                 from Main.cpp:1:
/usr/include/c++/13/bits/stl_queue.h:738:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = temptation; _Sequence = std::vector<temptation, std::allocator<temptation> >; _Compare = std::less<temptation>; value_type = temptation]'
  738 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:738:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<temptation>::value_type&' {aka 'const temptation&'}
  738 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_queue.h:746:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = temptation; _Sequence = std::vector<temptation, std::allocator<temptation> >; _Compare = std::less<temptation>; value_type = temptation]'
  746 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:746:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<temptation>::value_type&&' {aka 'temptation&&'}
  746 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
Main.cpp:40:24: error: 'groups' was not declared in this scope
   40 |         pq.push({val + groups[i+1][1] - groups[i+1][0], i + 1, 1});
      |                        ^~~~~~
Main.cpp:40:16: error: no matching function for call to 'std::priority_queue<temptation>::push(<brace-enclosed initializer list>)'
   40 |         pq.push({val + groups[i+1][1] - groups[i+1][0], i + 1, 1});
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_queue.h:738:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = temptation; _Sequence = std::vector<temptation, std::allocator<temptation> >; _Compare = std::less<temptation>; value_type = temptation]'
  738 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:738:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<temptation>::value_type&' {aka 'const temptation&'}
  738 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_queue.h:746:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = temptation; _Sequence = std::vector<temptation, std::allocator<temptation> >; _Compare = std::less<temptation>; value_type = temptation]'
  746 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:746:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<temptation>::value_type&&' {aka 'temptation&&'}
  746 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
Main.cpp:43:20: error: no matching function for call to 'std::priority_queue<temptation>::push(<brace-enclosed initializer list>)'
   43 |             pq.push({val - (groups[i][1] - groups[i][0]) + (groups[i+1][1] - groups[i+1][0]), i + 1, 1});
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_queue.h:738:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = temptation; _Sequence = std::vector<temptation, std::allocator<temptation> >; _Compare = std::less<temptation>; value_type = temptation]'
  738 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:738:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<temptation>::value_type&' {aka 'const temptation&'}
  738 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_queue.h:746:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = temptation; _Sequence = std::vector<temptation, std::allocator<temptation> >; _Compare = std::less<temptation>; value_type = temptation]'
  746 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:746:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<temptation>::value_type&&' {aka 'temptation&&'}
  746 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~