Submission #979667

# Submission time Handle Problem Language Result Execution time Memory
979667 2024-05-11T09:40:27 Z canadavid1 A Plus B (IOI23_aplusb) C++17
10 / 100
1 ms 348 KB
#include "aplusb.h"
#include <set>
#include <utility>
#include <tuple>
std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) {
  auto cmp = [&](auto a,auto b){return std::make_tuple(A[a.first]+B[a.second],a,b)<std::make_tuple(A[b.first]+B[b.second],a,b);};
  std::set<std::pair<int,int>,decltype(cmp)> q(cmp);
  std::vector<int> out;
  q.emplace(0,0);
  while(out.size()<N)
  {
    auto[a,b] = *q.begin();
    out.push_back(A[a]+B[b]);
    q.erase(q.begin());
    if(a+1<A.size()) q.emplace(a+1,b);
    if(b+1<B.size()) q.emplace(a,b+1);
  }
  return out;
}

Compilation message

aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
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(out.size()<N)
      |         ~~~~~~~~~~^~
aplusb.cpp:15:11: warning: comparison of integer expressions of different signedness: 'std::tuple_element<0, std::pair<int, int> >::type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     if(a+1<A.size()) q.emplace(a+1,b);
      |        ~~~^~~~~~~~~
aplusb.cpp:16:11: warning: comparison of integer expressions of different signedness: 'std::tuple_element<1, std::pair<int, int> >::type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     if(b+1<B.size()) q.emplace(a,b+1);
      |        ~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB 1st lines differ - on the 17th token, expected: '74', found: '140'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB 1st lines differ - on the 17th token, expected: '74', found: '140'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB 1st lines differ - on the 17th token, expected: '74', found: '140'
9 Halted 0 ms 0 KB -