Submission #971837

#TimeUsernameProblemLanguageResultExecution timeMemory
971837phoebeA Plus B (IOI23_aplusb)C++17
Compilation error
0 ms0 KiB
#include "aplusb.h" #include <bits/stdc++.h> using namespace std; vector<int> smallest_sums(int n, vector<int> a, vector<int> b){ priority_queue<pair<int, pii>> pq; set<pii> seen; vector<int> re; pq.push({-(a[0] + b[0]), {0, 0}}); while (re.size() < n){ int i = pq.second.first, j = pq.second.second; pq.pop(); if (seen.count({i, j})) continue; seen.insert({i, j}); re.push_back(a[i] + b[j]); if (i < n - 1) pq.push_back({-(a[i + 1] + b[j]), {i + 1, j}}); if (j < n - 1) pq.push_back({-(a[i] + b[j + 1]), {i, j + 1}}); } return re; }

Compilation message (stderr)

aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
aplusb.cpp:6:27: error: 'pii' was not declared in this scope
    6 |  priority_queue<pair<int, pii>> pq;
      |                           ^~~
aplusb.cpp:6:27: error: template argument 2 is invalid
aplusb.cpp:6:30: error: template argument 1 is invalid
    6 |  priority_queue<pair<int, pii>> pq;
      |                              ^~
aplusb.cpp:6:30: error: template argument 2 is invalid
aplusb.cpp:6:30: error: template argument 3 is invalid
aplusb.cpp:7:9: error: template argument 2 is invalid
    7 |  set<pii> seen;
      |         ^
aplusb.cpp:7:9: error: template argument 3 is invalid
aplusb.cpp:9:5: error: request for member 'push' in 'pq', which is of non-class type 'int'
    9 |  pq.push({-(a[0] + b[0]), {0, 0}});
      |     ^~~~
aplusb.cpp:10:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 |  while (re.size() < n){
      |         ~~~~~~~~~~^~~
aplusb.cpp:11:14: error: request for member 'second' in 'pq', which is of non-class type 'int'
   11 |   int i = pq.second.first, j = pq.second.second; pq.pop();
      |              ^~~~~~
aplusb.cpp:11:53: error: request for member 'pop' in 'pq', which is of non-class type 'int'
   11 |   int i = pq.second.first, j = pq.second.second; pq.pop();
      |                                                     ^~~
aplusb.cpp:12:12: error: request for member 'count' in 'seen', which is of non-class type 'int'
   12 |   if (seen.count({i, j})) continue;
      |            ^~~~~
aplusb.cpp:12:22: error: 'j' was not declared in this scope
   12 |   if (seen.count({i, j})) continue;
      |                      ^
aplusb.cpp:13:8: error: request for member 'insert' in 'seen', which is of non-class type 'int'
   13 |   seen.insert({i, j});
      |        ^~~~~~
aplusb.cpp:13:19: error: 'j' was not declared in this scope
   13 |   seen.insert({i, j});
      |                   ^
aplusb.cpp:15:21: error: request for member 'push_back' in 'pq', which is of non-class type 'int'
   15 |   if (i < n - 1) pq.push_back({-(a[i + 1] + b[j]), {i + 1, j}});
      |                     ^~~~~~~~~
aplusb.cpp:16:21: error: request for member 'push_back' in 'pq', which is of non-class type 'int'
   16 |   if (j < n - 1) pq.push_back({-(a[i] + b[j + 1]), {i, j + 1}});
      |                     ^~~~~~~~~