Submission #947808

# Submission time Handle Problem Language Result Execution time Memory
947808 2024-03-17T04:15:38 Z biank A Plus B (IOI23_aplusb) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "aplusb.h"

using namespace std;

#define sz(x) int(x.size())

using ii = pair<int, int>;
using vi = vector<int>;

vi smallest_sums(int n, vi a, vi b) {
    priority_queue<pair<int, ii>, vector<pair<int, ii>>, greater<pair<int, ii>>> pq;
    set<ii> vis;
    auto push = [&](int i, int j) {
        pq.emplace(a[i] + b[j], {i, j});
        vis.emplace(i, j);
    };
    push(0, 0);
    vi ans;
    while (sz(ans) < n) {
        auto [sum, pos] = pq.top();
        ans.push_back(sum);
        pq.pop();
        auto [i, j] = pos;
        if (i + 1 < n && !vis.count({i + 1, j})) {
            push(i + 1, j);
        }
        if (j + 1 < n && !vis.count({i, j + 1})) {
            push(i, j + 1);
        }
    }
	return {};
}

Compilation message

aplusb.cpp: In lambda function:
aplusb.cpp:15:39: error: no matching function for call to 'std::priority_queue<std::pair<int, std::pair<int, int> >, std::vector<std::pair<int, std::pair<int, int> > >, std::greater<std::pair<int, std::pair<int, int> > > >::emplace(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type, <brace-enclosed initializer list>)'
   15 |         pq.emplace(a[i] + b[j], {i, j});
      |                                       ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from aplusb.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:656:2: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::emplace(_Args&& ...) [with _Args = {}; _Tp = std::pair<int, std::pair<int, int> >; _Sequence = std::vector<std::pair<int, std::pair<int, int> > >; _Compare = std::greater<std::pair<int, std::pair<int, int> > >]'
  656 |  emplace(_Args&&... __args)
      |  ^~~~~~~
/usr/include/c++/10/bits/stl_queue.h:656:2: note:   candidate expects 0 arguments, 2 provided