답안 #840420

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
840420 2023-08-31T11:20:10 Z grossly_overconfident A Plus B (IOI23_aplusb) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "aplusb.h"
using namespace std;

vector<int> smallest_sums(int n, vector<int> a, vector<int> a) {
	priority_queue<pair<int, pair<int, int>>> pq;
	vector<int> out(n);
	set<pair<int, int>> visited;
	int f = 0;
	pq.push({a[0] + b[0], {0, 0}});
	for (int i = 0; i < n; ++i){
		auto h = pq.top();
		pq.pop();
		out[f] = h.first;
		f += 1;
		if (!visited.count({h.second.first + 1, h.second.second})){
			pq.push({a[h.second.first + 1] + b[h.second.second], {h.second.first + 1, h.second.second}});
			visited.insert({h.second.first + 1, h.second.second});
		}
		if (!visited.count({h.second.first, h.second.second + 1})){
			pq.push({a[h.second.first] + b[h.second.second + 1], {h.second.first, h.second.second + 1}});
			visited.insert({h.second.first, h.second.second + 1});
		}
	}
	return out;
}

Compilation message

aplusb.cpp:5:61: error: redefinition of 'std::vector<int> a'
    5 | vector<int> smallest_sums(int n, vector<int> a, vector<int> a) {
      |                                                 ~~~~~~~~~~~~^
aplusb.cpp:5:46: note: 'std::vector<int> a' previously declared here
    5 | vector<int> smallest_sums(int n, vector<int> a, vector<int> a) {
      |                                  ~~~~~~~~~~~~^
aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>)':
aplusb.cpp:10:18: error: 'b' was not declared in this scope
   10 |  pq.push({a[0] + b[0], {0, 0}});
      |                  ^
aplusb.cpp:10:31: error: no matching function for call to 'std::priority_queue<std::pair<int, std::pair<int, int> > >::push(<brace-enclosed initializer list>)'
   10 |  pq.push({a[0] + b[0], {0, 0}});
      |                               ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from aplusb.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, std::pair<int, int> >; _Sequence = std::vector<std::pair<int, std::pair<int, int> >, std::allocator<std::pair<int, std::pair<int, int> > > >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, std::pair<int, int> >]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, std::pair<int, int> >&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<int, std::pair<int, int> >; _Sequence = std::vector<std::pair<int, std::pair<int, int> >, std::allocator<std::pair<int, std::pair<int, int> > > >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, std::pair<int, int> >]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<int, std::pair<int, int> > >::value_type&&' {aka 'std::pair<int, std::pair<int, int> >&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
aplusb.cpp:17:95: error: no matching function for call to 'std::priority_queue<std::pair<int, std::pair<int, int> > >::push(<brace-enclosed initializer list>)'
   17 |    pq.push({a[h.second.first + 1] + b[h.second.second], {h.second.first + 1, h.second.second}});
      |                                                                                               ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from aplusb.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, std::pair<int, int> >; _Sequence = std::vector<std::pair<int, std::pair<int, int> >, std::allocator<std::pair<int, std::pair<int, int> > > >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, std::pair<int, int> >]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, std::pair<int, int> >&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<int, std::pair<int, int> >; _Sequence = std::vector<std::pair<int, std::pair<int, int> >, std::allocator<std::pair<int, std::pair<int, int> > > >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, std::pair<int, int> >]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<int, std::pair<int, int> > >::value_type&&' {aka 'std::pair<int, std::pair<int, int> >&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
aplusb.cpp:21:95: error: no matching function for call to 'std::priority_queue<std::pair<int, std::pair<int, int> > >::push(<brace-enclosed initializer list>)'
   21 |    pq.push({a[h.second.first] + b[h.second.second + 1], {h.second.first, h.second.second + 1}});
      |                                                                                               ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from aplusb.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, std::pair<int, int> >; _Sequence = std::vector<std::pair<int, std::pair<int, int> >, std::allocator<std::pair<int, std::pair<int, int> > > >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, std::pair<int, int> >]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, std::pair<int, int> >&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<int, std::pair<int, int> >; _Sequence = std::vector<std::pair<int, std::pair<int, int> >, std::allocator<std::pair<int, std::pair<int, int> > > >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, std::pair<int, int> >]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<int, std::pair<int, int> > >::value_type&&' {aka 'std::pair<int, std::pair<int, int> >&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~