Submission #947807

#TimeUsernameProblemLanguageResultExecution timeMemory
947807biankA Plus B (IOI23_aplusb)C++17
Compilation error
0 ms0 KiB
#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> visited; 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 (stderr)

aplusb.cpp: In lambda function:
aplusb.cpp:15:20: error: 'a' was not declared in this scope
   15 |         pq.emplace(a[i] + b[j], {i, j});
      |                    ^
aplusb.cpp:15:27: error: 'b' was not declared in this scope
   15 |         pq.emplace(a[i] + b[j], {i, j});
      |                           ^
aplusb.cpp:16:9: error: 'vis' was not declared in this scope; did you mean 'vi'?
   16 |         vis.emplace(i, j);
      |         ^~~
      |         vi
aplusb.cpp: In function 'vi smallest_sums(int, vi, vi)':
aplusb.cpp:25:27: error: 'vis' was not declared in this scope; did you mean 'vi'?
   25 |         if (i + 1 < N && !vis.count({i + 1, j})) {
      |                           ^~~
      |                           vi
aplusb.cpp:28:27: error: 'vis' was not declared in this scope; did you mean 'vi'?
   28 |         if (j + 1 < N && !vis.count({i, j + 1})) {
      |                           ^~~
      |                           vi