제출 #979661

#제출 시각아이디문제언어결과실행 시간메모리
979661canadavid1A Plus B (IOI23_aplusb)C++17
컴파일 에러
0 ms0 KiB
#include "aplusb.h" #include <set> #include <utility> std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) { auto cmp = [&](auto a,auto b){return A[a.first]+B[a.second]<A[b.first]+B[b.second];}; 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] = *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; }

컴파일 시 표준 에러 (stderr) 메시지

aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
aplusb.cpp:9:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    9 |    while(out.size()<N)
      |          ~~~~~~~~~~^~
aplusb.cpp:11:11: error: cannot decompose non-array non-class type 'int'
   11 |       auto[a,b] = *out.begin();
      |           ^~~~~
aplusb.cpp:12:11: error: 'class std::vector<int>' has no member named 'push'
   12 |       out.push(A[a]+B[b]);
      |           ^~~~