Submission #149126

# Submission time Handle Problem Language Result Execution time Memory
149126 2019-09-01T05:46:59 Z Little Piplup(#3742, gratus907, DHdroid, coffeetea99) Crosses on the Grid (FXCUP4_cross) C++17
Compilation error
0 ms 0 KB
#include "cross.h"
#include<bits/stdc++.h>
//using namespace std;

long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
	int N = I.size();

	std::pair<long long, long long> soo[N];
	for ( int i = 0 ; i < N ; ++i ) {
		soo[i] = {O[i], I[i]};
	}
	sort(soo, soo + N, std::greater< std::pair<long long, long long> >());

	std::priority_queue<long long, std::vector<long long>, std::greater<long long>()> puts;
	for ( int i = 0 ; i < K ; ++i ) {
		puts.push(soo[i].second);
	}
	long long out = soo[K-1].first;
	long long in = puts.top();
	long long ret = out * out - in * in;

	for ( int i = K ; i < N ; ++i ) {
		out = soo[i].first;
		puts.pop();
		puts.push(soo[i].second);
		in = puts.top();
		ret = std::max(ret, out * out - in * in);
	}

	return ret;
}

Compilation message

In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from cross.cpp:2:
/usr/include/c++/7/bits/stl_queue.h: In instantiation of 'class std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int>()>':
cross.cpp:14:84:   required from here
/usr/include/c++/7/bits/stl_queue.h:457:18: error: field 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int>()>::comp' invalidly declared function type
       _Compare   comp;
                  ^~~~
cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:14:84: error: no matching function for call to 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int>()>::priority_queue()'
  std::priority_queue<long long, std::vector<long long>, std::greater<long long>()> puts;
                                                                                    ^~~~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from cross.cpp:2:
/usr/include/c++/7/bits/stl_queue.h:552:2: note: candidate: template<class _InputIterator> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&)
  priority_queue(_InputIterator __first, _InputIterator __last,
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:552:2: note:   template argument deduction/substitution failed:
cross.cpp:14:84: note:   candidate expects 4 arguments, 0 provided
  std::priority_queue<long long, std::vector<long long>, std::greater<long long>()> puts;
                                                                                    ^~~~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from cross.cpp:2:
/usr/include/c++/7/bits/stl_queue.h:541:2: note: candidate: template<class _InputIterator> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&)
  priority_queue(_InputIterator __first, _InputIterator __last,
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:541:2: note:   template argument deduction/substitution failed:
cross.cpp:14:84: note:   candidate expects 4 arguments, 0 provided
  std::priority_queue<long long, std::vector<long long>, std::greater<long long>()> puts;
                                                                                    ^~~~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from cross.cpp:2:
/usr/include/c++/7/bits/stl_queue.h:509:2: note: candidate: template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(std::priority_queue<_Tp, _Sequence, _Compare>&&, const _Alloc&)
  priority_queue(priority_queue&& __q, const _Alloc& __a)
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:509:2: note:   template argument deduction/substitution failed:
cross.cpp:14:84: note:   candidate expects 2 arguments, 0 provided
  std::priority_queue<long long, std::vector<long long>, std::greater<long long>()> puts;
                                                                                    ^~~~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from cross.cpp:2:
/usr/include/c++/7/bits/stl_queue.h:505:2: note: candidate: template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const std::priority_queue<_Tp, _Sequence, _Compare>&, const _Alloc&)
  priority_queue(const priority_queue& __q, const _Alloc& __a)
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:505:2: note:   template argument deduction/substitution failed:
cross.cpp:14:84: note:   candidate expects 2 arguments, 0 provided
  std::priority_queue<long long, std::vector<long long>, std::greater<long long>()> puts;
                                                                                    ^~~~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from cross.cpp:2:
/usr/include/c++/7/bits/stl_queue.h:501:2: note: candidate: template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&, const _Alloc&)
  priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a)
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:501:2: note:   template argument deduction/substitution failed:
cross.cpp:14:84: note:   candidate expects 3 arguments, 0 provided
  std::priority_queue<long long, std::vector<long long>, std::greater<long long>()> puts;
                                                                                    ^~~~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from cross.cpp:2:
/usr/include/c++/7/bits/stl_queue.h:496:2: note: candidate: template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&, const _Alloc&)
  priority_queue(const _Compare& __x, const _Sequence& __c,
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:496:2: note:   template argument deduction/substitution failed:
cross.cpp:14:84: note:   candidate expects 3 arguments, 0 provided
  std::priority_queue<long long, std::vector<long long>, std::greater<long long>()> puts;
                                                                                    ^~~~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from cross.cpp:2:
/usr/include/c++/7/bits/stl_queue.h:492:2: note: candidate: template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Alloc&)
  priority_queue(const _Compare& __x, const _Alloc& __a)
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:492:2: note:   template argument deduction/substitution failed:
cross.cpp:14:84: note:   candidate expects 2 arguments, 0 provided
  std::priority_queue<long long, std::vector<long long>, std::greater<long long>()> puts;
                                                                                    ^~~~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from cross.cpp:2:
/usr/include/c++/7/bits/stl_queue.h:488:2: note: candidate: template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Alloc&)
  priority_queue(const _Alloc& __a)
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:488:2: note:   template argument deduction/substitution failed:
cross.cpp:14:84: note:   candidate expects 1 argument, 0 provided
  std::priority_queue<long long, std::vector<long long>, std::greater<long long>()> puts;
                                                                                    ^~~~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from cross.cpp:2:
/usr/include/c++/7/bits/stl_queue.h:482:7: note: candidate: std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&) [with _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]
       priority_queue(const _Compare& __x, _Sequence&& __s = _Sequence())
       ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:482:7: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/7/bits/stl_queue.h:477:7: note: candidate: std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&) [with _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]
       priority_queue(const _Compare& __x, const _Sequence& __s)
       ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:477:7: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/7/bits/stl_queue.h:473:2: note: candidate: template<class _Seq, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue()
  priority_queue()
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:473:2: note:   template argument deduction/substitution failed:
/usr/include/c++/7/bits/stl_queue.h:470:43: error: no type named 'type' in 'struct std::enable_if<false, void>'
       template<typename _Seq = _Sequence, typename _Requires = typename
                                           ^~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:423:11: note: candidate: std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int>()>::priority_queue(const std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int>()>&)
     class priority_queue
           ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:423:11: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/7/bits/stl_queue.h:423:11: note: candidate: std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int>()>::priority_queue(std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int>()>&&)
/usr/include/c++/7/bits/stl_queue.h:423:11: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/7/vector:60,
                 from cross.h:2,
                 from cross.cpp:1:
/usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; _Value = long long int; _Compare = std::greater<long long int> (*)()]':
/usr/include/c++/7/bits/stl_heap.h:133:48:   required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; _Distance = long int; _Tp = long long int; _Compare = __gnu_cxx::__ops::_Iter_comp_val<std::greater<long long int> (*)()>]'
/usr/include/c++/7/bits/stl_heap.h:207:23:   required from 'void std::push_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; _Compare = std::greater<long long int> (*)()]'
/usr/include/c++/7/bits/stl_queue.h:598:16:   required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>(); std::priority_queue<_Tp, _Sequence, _Compare>::value_type = long long int]'
cross.cpp:16:26:   required from here
/usr/include/c++/7/bits/predefined_ops.h:177:11: error: too many arguments to function
  { return bool(_M_comp(*__it, __val)); }
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/predefined_ops.h:177:11: error: invalid cast from type 'std::greater<long long int>' to type 'bool'
/usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; _Iterator2 = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; _Compare = std::greater<long long int> (*)()]':
/usr/include/c++/7/bits/stl_heap.h:222:14:   required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; _Distance = long int; _Tp = long long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<std::greater<long long int> (*)()>]'
/usr/include/c++/7/bits/stl_heap.h:253:25:   required from 'void std::__pop_heap(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<std::greater<long long int> (*)()>]'
/usr/include/c++/7/bits/stl_heap.h:320:19:   required from 'void std::pop_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; _Compare = std::greater<long long int> (*)()]'
/usr/include/c++/7/bits/stl_queue.h:633:15:   required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::pop() [with _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>()]'
cross.cpp:24:12:   required from here
/usr/include/c++/7/bits/predefined_ops.h:143:18: error: too many arguments to function
         { return bool(_M_comp(*__it1, *__it2)); }
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/predefined_ops.h:143:18: error: invalid cast from type 'std::greater<long long int>' to type 'bool'