답안 #979659

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
979659 2024-05-11T09:34:06 Z canadavid1 A Plus B (IOI23_aplusb) C++17
컴파일 오류
0 ms 0 KB
#include "aplusb.h"
#include <set>
#include <utility>
std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) {
	std::set<std::pair<int,int>,[](auto a,auto b){return A[a.first]+B[a.second]<A[b.first]+B[b.second];}> q;
  	std::vector<int> out;
  	q.emplace(0,0);
  	while(out.size()<N)
    {
      auto[a,b] = *out.begin();
      out.push(A[a]+B[b]);
      out.erase(out.begin());
      if(a+1<N) out.emplace(a+1,b);
      if(b+1<N) out.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:5:30: error: lambda-expression in template-argument only available with '-std=c++2a' or '-std=gnu++2a'
    5 |  std::set<std::pair<int,int>,[](auto a,auto b){return A[a.first]+B[a.second]<A[b.first]+B[b.second];}> q;
      |                              ^
aplusb.cpp:5:102: error: template argument 2 is invalid
    5 |  std::set<std::pair<int,int>,[](auto a,auto b){return A[a.first]+B[a.second]<A[b.first]+B[b.second];}> q;
      |                                                                                                      ^
aplusb.cpp:7:6: error: request for member 'emplace' in 'q', which is of non-class type 'int'
    7 |    q.emplace(0,0);
      |      ^~~~~~~
aplusb.cpp:8:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    8 |    while(out.size()<N)
      |          ~~~~~~~~~~^~
aplusb.cpp:10:11: error: cannot decompose non-array non-class type 'int'
   10 |       auto[a,b] = *out.begin();
      |           ^~~~~
aplusb.cpp:11:11: error: 'class std::vector<int>' has no member named 'push'
   11 |       out.push(A[a]+B[b]);
      |           ^~~~