Submission #406507

# Submission time Handle Problem Language Result Execution time Memory
406507 2021-05-17T17:05:31 Z Iwanttobreakfree Jelly Flavours (IOI20_jelly) C++17
Compilation error
0 ms 0 KB
#include "jelly.h"
#include <vector>
#include <algorithm>
using namespace std;
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
	int n=a.size();
	vector<pair<int,int> >an,bn;
	vector<bool> visto(n,false);
	an.assign(n);
	bn.assign(n);
	for(int i=0;i<n;i++){
		an[i]=make_pair(a[i],i);
		bn[i]=make_pair(b[i],i);
	}
	sort(an.begin(),bn.end());
	sort(bn.begin(),bn.end());
	if(y==0){
		for(int i=0;i<n;i++){
			if(bn[i]==0)visto[bn[i].second]=true;
			else break;
		}
		int cont=0;
		for(int i=0;i<n;i++){
			if(visto[an[cont].second])continue;
			if(x-an[cont].first>-1){
			cont++;
			x-=an[cont].first;
		}
		else break;
		}
		return cont;
	}
	if(x==0){
		for(int i=0;i<n;i++){
			if(an[i]==0)visto[an[i].second]=true;
			else break;
		}
		int cont=0;
		for(int i=0;i<n;i++){
			if(visto[bn[cont].second])continue;
			if(x-bn[cont].first>-1){
			cont++;
			x-=bn[cont].first;
		}
		else break;
		}
		return cont;
	}
	return n;
}

Compilation message

jelly.cpp: In function 'int find_maximum_unique(int, int, std::vector<int>, std::vector<int>)':
jelly.cpp:9:13: error: no matching function for call to 'std::vector<std::pair<int, int> >::assign(int&)'
    9 |  an.assign(n);
      |             ^
In file included from /usr/include/c++/10/vector:67,
                 from jelly.h:1,
                 from jelly.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:749:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
  749 |       assign(size_type __n, const value_type& __val)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:749:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:768:2: note: candidate: 'template<class _InputIterator, class> void std::vector<_Tp, _Alloc>::assign(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  768 |  assign(_InputIterator __first, _InputIterator __last)
      |  ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:768:2: note:   template argument deduction/substitution failed:
jelly.cpp:9:13: note:   candidate expects 2 arguments, 1 provided
    9 |  an.assign(n);
      |             ^
In file included from /usr/include/c++/10/vector:67,
                 from jelly.h:1,
                 from jelly.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:794:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::initializer_list<_Tp>) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  794 |       assign(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:794:43: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<std::pair<int, int> >'
  794 |       assign(initializer_list<value_type> __l)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
jelly.cpp:10:13: error: no matching function for call to 'std::vector<std::pair<int, int> >::assign(int&)'
   10 |  bn.assign(n);
      |             ^
In file included from /usr/include/c++/10/vector:67,
                 from jelly.h:1,
                 from jelly.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:749:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
  749 |       assign(size_type __n, const value_type& __val)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:749:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:768:2: note: candidate: 'template<class _InputIterator, class> void std::vector<_Tp, _Alloc>::assign(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  768 |  assign(_InputIterator __first, _InputIterator __last)
      |  ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:768:2: note:   template argument deduction/substitution failed:
jelly.cpp:10:13: note:   candidate expects 2 arguments, 1 provided
   10 |  bn.assign(n);
      |             ^
In file included from /usr/include/c++/10/vector:67,
                 from jelly.h:1,
                 from jelly.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:794:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::initializer_list<_Tp>) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  794 |       assign(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:794:43: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<std::pair<int, int> >'
  794 |       assign(initializer_list<value_type> __l)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
jelly.cpp:19:12: error: no match for 'operator==' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
   19 |    if(bn[i]==0)visto[bn[i].second]=true;
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from jelly.h:1,
                 from jelly.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:466:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)'
  466 |     operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:466:5: note:   template argument deduction/substitution failed:
jelly.cpp:19:14: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
   19 |    if(bn[i]==0)visto[bn[i].second]=true;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/vector:60,
                 from jelly.h:1,
                 from jelly.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:360:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)'
  360 |     operator==(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:360:5: note:   template argument deduction/substitution failed:
jelly.cpp:19:14: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::reverse_iterator<_Iterator>'
   19 |    if(bn[i]==0)visto[bn[i].second]=true;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/vector:60,
                 from jelly.h:1,
                 from jelly.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:398:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)'
  398 |     operator==(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:398:5: note:   template argument deduction/substitution failed:
jelly.cpp:19:14: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::reverse_iterator<_Iterator>'
   19 |    if(bn[i]==0)visto[bn[i].second]=true;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/vector:60,
                 from jelly.h:1,
                 from jelly.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:1427:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)'
 1427 |     operator==(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1427:5: note:   template argument deduction/substitution failed:
jelly.cpp:19:14: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::move_iterator<_IteratorL>'
   19 |    if(bn[i]==0)visto[bn[i].second]=true;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/vector:60,
                 from jelly.h:1,
                 from jelly.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:1495:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&)'
 1495 |     operator==(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1495:5: note:   template argument deduction/substitution failed:
jelly.cpp:19:14: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::move_iterator<_IteratorL>'
   19 |    if(bn[i]==0)visto[bn[i].second]=true;
      |              ^
In file included from /usr/include/c++/10/vector:64,
                 from jelly.h:1,
                 from jelly.cpp:1:
/usr/include/c++/10/bits/allocator.h:206:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const std::allocator<_Tp1>&, const std::allocator<_T2>&)'
  206 |     operator==(const allocator<_T1>&, const allocator<_T2>&)
      |     ^~~~~~~~
/usr/include/c++/10/bits/allocator.h:206:5: note:   template argument deduction/substitution failed:
jelly.cpp:19:14: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::allocator<_Tp1>'
   19 |    if(bn[i]==0)visto[bn[i].second]=true;
      |              ^
In file included from /usr/include/c++/10/vector:67,
                 from jelly.h:1,
                 from jelly.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1892:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator==(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)'
 1892 |     operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1892:5: note:   template argument deduction/substitution failed:
jelly.cpp:19:14: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::vector<_Tp, _Alloc>'
   19 |    if(bn[i]==0)visto[bn[i].second]=true;
      |              ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from jelly.cpp:3:
/usr/include/c++/10/array:253:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> bool std::operator==(const std::array<_Tp, _Nm>&, const std::array<_Tp, _Nm>&)'
  253 |     operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
      |     ^~~~~~~~
/usr/include/c++/10/array:253:5: note:   template argument deduction/substitution failed:
jelly.cpp:19:14: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::array<_Tp, _Nm>'
   19 |    if(bn[i]==0)visto[bn[i].second]=true;
      |              ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from jelly.cpp:3:
/usr/include/c++/10/tuple:1393:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const std::tuple<_Tps ...>&, const std::tuple<_UTypes ...>&)'
 1393 |     operator==(const tuple<_TElements...>& __t,
      |     ^~~~~~~~
/usr/include/c++/10/tuple:1393:5: note:   template argument deduction/substitution failed:
jelly.cpp:19:14: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::tuple<_Tps ...>'
   19 |    if(bn[i]==0)visto[bn[i].second]=true;
      |              ^
In file included from /usr/include/c++/10/functional:59,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from jelly.cpp:3:
/usr/include/c++/10/bits/std_function.h:680:5: note: candidate: 'template<class _Res, class ... _Args> bool std::operator==(const std::function<_Res(_ArgTypes ...)>&, std::nullptr_t)'
  680 |     operator==(const function<_Res(_Args...)>& __f, nullptr_t) noexcept
      |     ^~~~~~~~
/usr/include/c++/10/bits/std_function.h:680:5: note:   template argument deduction/substitution failed:
jelly.cpp:19:14: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::function<_Res(_ArgTypes ...)>'
   19 |    if(bn[i]==0)visto[bn[i].second]=true;
      |              ^
In file included from /usr/include/c++/10/functional:59,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from jelly.cpp:3:
/usr/include/c++/10/bits/std_function.h:687:5: note: candidate: 'template<class _Res, class ... _Args> bool std::operator==(std::nullptr_t, const std::function<_Res(_ArgTypes ...)>&)'
  687 |     operator==(nullptr_t, const function<_Res(_Args...)>& __f) noexcept
      |     ^~~~~~~~
/usr/include/c++/10/bits/std_function.h:687:5: note:   template argument deduction/substitution failed:
jelly.cpp:19:14: note:   mismatched types 'const std::function<_Res(_ArgTypes ...)>' and 'int'
   19 |    if(bn[i]==0)visto[bn[i].second]=true;
      |              ^
In file included from /usr/include/c++/10/bits/node_handle.h:39,
                 from /usr/include/c++/10/bits/hashtable.h:37,
                 from /usr/include/c++/10/unordered_map:46,
                 from /usr/include/c++/10/functional:61,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from jelly.cpp:3:
/usr/include/c++/10/optional:985:5: note: candidate: 'template<class _Tp, class _Up> constexpr std::__optional_relop_t<decltype ((declval<_Tp>() == declval<_Up>()))> std::operator==(const std::optional<_Tp>&, const std::optional<_Up>&)'
  985 |     operator==(const optional<_Tp>& __lhs, const optional<_Up>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/10/optional:985:5: note:   template argument deduction/substitution failed:
jelly.cpp:19:14: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::optional<_Tp>'
   19 |    if(bn[i]==0)visto[bn[i].second]=true;
      |              ^
In file included from /usr/include/c++/10/bits/node_handle.h:39,
                 from /usr/include/c++/10/bits/hashtable.h:37,
                 from /usr/include/c++/10/unordered_map:46,
                 from /usr/include/c++/10/functional:61,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from jelly.cpp:3:
/usr/include/c++/10/optional:1045:5: note: candidate: 'template<class _Tp> constexpr bool std::operator==(const std::optional<_Tp>&, std::nullopt_t)'
 1045 |     operator==(const optional<_Tp>& __lhs, nullopt_t) noexcept
      |     ^~~~~~~~
/usr/include/c++/10/optional:1045:5: note:   template argument deduction/substitution failed:
jelly.cpp:19:14: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::optional<_Tp>'
   19 |    if(bn[i]==0)visto[bn[i].second]=true;
      |              ^
In file included from /usr/include/c++/10/bits/node_handle.h:39,
                 from /usr/include/c++/10/bits/hashtable.h:37,
                 from /usr/include/c++/10/unordered_map:46,
                 from /usr/include/c++/10/functional:61,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from jelly.cpp:3:
/usr/include/c++/10/optional:1056:5: note: candidate: 'template<class _Tp> constexpr bool std::operator==(std::nullopt_t, const std::optional<_Tp>&)'
 1056 |     operator==(nullopt_t, const optional<_Tp>& __rhs) noexcept
      |     ^~~~~~~~
/usr/include/c++/10/optional:1056:5: note:   template argument deduction/substitution failed:
jelly.cpp:19:14: note:   mismatched types 'const std::optional<_Tp>' and 'int'
   19 |    if(bn[i]==0)visto[bn[i].second]=true;
      |              ^
In file included from /usr/include/c++/10/bits/node_handle.h:39,
                 from /usr/include/c++/10/bits/hashtable.h:37,
                 from /usr/include/c++/10/unordered_map:46,
                 from /usr/include/c++/10/functional:61,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from jelly.cpp:3:
/usr/include/c++/10/optional:1113:5: note: candidate: 'template<class _Tp, class _Up> constexpr std::__optional_relop_t<decltype ((declval<_Tp>() == declval<_Up>()))> std::operator==(const std::optional<_Tp>&, const _Up&)'
 1113 |     operator==(const optional<_Tp>& __lhs, const _Up& __rhs)
      |     ^~~~~~~~
/usr/include/c++/10/optional:1113:5: note:   template argument deduction/substitution failed:
jelly.cpp:19:14: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::optional<_Tp>'
   19 |    if(bn[i]==0)visto[bn[i].second]=true;
      |              ^
In file included from /usr/include/c++/10/bits/node_handle.h:39,
                 from /usr/include/c++/10/bits/hashtable.h:37,
                 from /usr/include/c++/10/unordered_map:46,
                 from /usr/include/c++/10/functional:61,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from jelly.cpp:3:
/usr/include/c++/10/optional:1119:5: note: candidate: 'template<class _Tp, class _Up> cons