# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
46317 | rajarshi_basu | Teams (IOI15_teams) | C++14 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long int
#define pb(a) push_back(a)
#define vi vector<int>
#define ii pair<int,int>
#define iii pair<pair<int,int>, int>
#define mp(a,b) make_pair(a,b)
using namespace std;
int n;
int* a;
int* b;
struct info{
int st;
int end;
};
info* arr;
bool comp(info& a,info& b){
return a.end > b.end;
}
void init(int N,int* A,int* B){
n=N;
a = A;
b = B;
info* arr = new info[n];
FOR(i,n)arr[i].st = a[i];
FOR(i,n)arr[i].end = b[i];
sort(arr,arr+n);
}
int call(int m,int* k){
priority_queue<info, vector<info>, comp> pq;
int PTR = 0;
FOR(i,m){
while(arr[PTR]<=k[i])pq.push(arr[PTR++]);
int ctr = k[i];
while(!pq.empty() && pq.top().end < ctr)pq.pop();
while(!pq.empty() && pq.top().end < k[i] && ctr > 0){
pq.pop();
ctr--;
}
if(ctr > 0)return 0;
}
return 1;
}
Compilation message (stderr)
teams.cpp: In function 'bool comp(info&, info&)': teams.cpp:28:26: warning: declaration of 'b' shadows a global declaration [-Wshadow] bool comp(info& a,info& b){ ^ teams.cpp:22:6: note: shadowed declaration is here int* b; ^ teams.cpp:28:26: warning: declaration of 'a' shadows a global declaration [-Wshadow] bool comp(info& a,info& b){ ^ teams.cpp:21:6: note: shadowed declaration is here int* a; ^ teams.cpp: In function 'void init(int, int*, int*)': teams.cpp:35:9: warning: declaration of 'arr' shadows a global declaration [-Wshadow] info* arr = new info[n]; ^~~ teams.cpp:27:7: note: shadowed declaration is here info* arr; ^~~ teams.cpp: In function 'int call(int, int*)': teams.cpp:42:42: error: type/value mismatch at argument 3 in template parameter list for 'template<class _Tp, class _Sequence, class _Compare> class std::priority_queue' priority_queue<info, vector<info>, comp> pq; ^ teams.cpp:42:42: note: expected a type, got 'comp' teams.cpp:45:19: error: no match for 'operator<=' (operand types are 'info' and 'int') while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ~~~~~~~~^~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from teams.cpp:1: /usr/include/c++/7/bits/stl_pair.h:468:5: note: candidate: template<class _T1, class _T2> constexpr bool std::operator<=(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&) operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) ^~~~~~~~ /usr/include/c++/7/bits/stl_pair.h:468:5: note: template argument deduction/substitution failed: teams.cpp:45:24: note: 'info' is not derived from 'const std::pair<_T1, _T2>' while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ^ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from teams.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:323:5: note: candidate: template<class _Iterator> bool std::operator<=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&) operator<=(const reverse_iterator<_Iterator>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:323:5: note: template argument deduction/substitution failed: teams.cpp:45:24: note: 'info' is not derived from 'const std::reverse_iterator<_Iterator>' while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ^ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from teams.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:361:5: note: candidate: template<class _IteratorL, class _IteratorR> bool std::operator<=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&) operator<=(const reverse_iterator<_IteratorL>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:361:5: note: template argument deduction/substitution failed: teams.cpp:45:24: note: 'info' is not derived from 'const std::reverse_iterator<_Iterator>' while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ^ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from teams.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:1154:5: note: candidate: template<class _IteratorL, class _IteratorR> bool std::operator<=(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&) operator<=(const move_iterator<_IteratorL>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:1154:5: note: template argument deduction/substitution failed: teams.cpp:45:24: note: 'info' is not derived from 'const std::move_iterator<_IteratorL>' while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ^ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from teams.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:1160:5: note: candidate: template<class _Iterator> bool std::operator<=(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&) operator<=(const move_iterator<_Iterator>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:1160:5: note: template argument deduction/substitution failed: teams.cpp:45:24: note: 'info' is not derived from 'const std::move_iterator<_IteratorL>' while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from teams.cpp:1: /usr/include/c++/7/bits/basic_string.h:6158:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator<=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:6158:5: note: template argument deduction/substitution failed: teams.cpp:45:24: note: 'info' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from teams.cpp:1: /usr/include/c++/7/bits/basic_string.h:6171:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator<=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*) operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:6171:5: note: template argument deduction/substitution failed: teams.cpp:45:24: note: 'info' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from teams.cpp:1: /usr/include/c++/7/bits/basic_string.h:6183:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator<=(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) operator<=(const _CharT* __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:6183:5: note: template argument deduction/substitution failed: teams.cpp:45:24: note: mismatched types 'const _CharT*' and 'info' while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ^ In file included from /usr/include/c++/7/vector:64:0, from teams.cpp:3: /usr/include/c++/7/bits/stl_vector.h:1632:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator<=(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&) operator<=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) ^~~~~~~~ /usr/include/c++/7/bits/stl_vector.h:1632:5: note: template argument deduction/substitution failed: teams.cpp:45:24: note: 'info' is not derived from 'const std::vector<_Tp, _Alloc>' while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ^ In file included from /usr/include/c++/7/deque:64:0, from /usr/include/c++/7/stack:60, from teams.cpp:4: /usr/include/c++/7/bits/stl_deque.h:321:5: note: candidate: template<class _Tp, class _Ref, class _Ptr> bool std::operator<=(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _Ref, _Ptr>&) operator<=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_deque.h:321:5: note: template argument deduction/substitution failed: teams.cpp:45:24: note: 'info' is not derived from 'const std::_Deque_iterator<_Tp, _Ref, _Ptr>' while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ^ In file included from /usr/include/c++/7/deque:64:0, from /usr/include/c++/7/stack:60, from teams.cpp:4: /usr/include/c++/7/bits/stl_deque.h:328:5: note: candidate: template<class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR> bool std::operator<=(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _RefR, _PtrR>&) operator<=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_deque.h:328:5: note: template argument deduction/substitution failed: teams.cpp:45:24: note: 'info' is not derived from 'const std::_Deque_iterator<_Tp, _Ref, _Ptr>' while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ^ In file included from /usr/include/c++/7/deque:64:0, from /usr/include/c++/7/stack:60, from teams.cpp:4: /usr/include/c++/7/bits/stl_deque.h:2298:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator<=(const std::deque<_Tp, _Alloc>&, const std::deque<_Tp, _Alloc>&) operator<=(const deque<_Tp, _Alloc>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_deque.h:2298:5: note: template argument deduction/substitution failed: teams.cpp:45:24: note: 'info' is not derived from 'const std::deque<_Tp, _Alloc>' while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ^ In file included from /usr/include/c++/7/stack:61:0, from teams.cpp:4: /usr/include/c++/7/bits/stl_stack.h:329:5: note: candidate: template<class _Tp, class _Seq> bool std::operator<=(const std::stack<_Tp, _Seq>&, const std::stack<_Tp, _Seq>&) operator<=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) ^~~~~~~~ /usr/include/c++/7/bits/stl_stack.h:329:5: note: template argument deduction/substitution failed: teams.cpp:45:24: note: 'info' is not derived from 'const std::stack<_Tp, _Seq>' while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ^ In file included from /usr/include/c++/7/queue:64:0, from teams.cpp:5: /usr/include/c++/7/bits/stl_queue.h:354:5: note: candidate: template<class _Tp, class _Seq> bool std::operator<=(const std::queue<_Tp, _Seq>&, const std::queue<_Tp, _Seq>&) operator<=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) ^~~~~~~~ /usr/include/c++/7/bits/stl_queue.h:354:5: note: template argument deduction/substitution failed: teams.cpp:45:24: note: 'info' is not derived from 'const std::queue<_Tp, _Seq>' while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ^ In file included from /usr/include/c++/7/tuple:39:0, from /usr/include/c++/7/functional:54, from teams.cpp:7: /usr/include/c++/7/array:275:5: note: candidate: template<class _Tp, long unsigned int _Nm> bool std::operator<=(const std::array<_Tp, _Nm>&, const std::array<_Tp, _Nm>&) operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) ^~~~~~~~ /usr/include/c++/7/array:275:5: note: template argument deduction/substitution failed: teams.cpp:45:24: note: 'info' is not derived from 'const std::array<_Tp, _Nm>' while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ^ In file included from /usr/include/c++/7/functional:54:0, from teams.cpp:7: /usr/include/c++/7/tuple:1435:5: note: candidate: template<class ... _TElements, class ... _UElements> constexpr bool std::operator<=(const std::tuple<_Tps ...>&, const std::tuple<_Elements ...>&) operator<=(const tuple<_TElements...>& __t, ^~~~~~~~ /usr/include/c++/7/tuple:1435:5: note: template argument deduction/substitution failed: teams.cpp:45:24: note: 'info' is not derived from 'const std::tuple<_Tps ...>' while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ^ teams.cpp:45:29: error: request for member 'push' in 'pq', which is of non-class type 'int' while(arr[PTR]<=k[i])pq.push(arr[PTR++]); ^~~~ teams.cpp:47:15: error: request for member 'empty' in 'pq', which is of non-class type 'int' while(!pq.empty() && pq.top().end < ctr)pq.pop(); ^~~~~ teams.cpp:47:29: error: request for member 'top' in 'pq', which is of non-class type 'int' while(!pq.empty() && pq.top().end < ctr)pq.pop(); ^~~ teams.cpp:47:48: error: request for member 'pop' in 'pq', which is of non-class type 'int' while(!pq.empty() && pq.top().end < ctr)pq.pop(); ^~~ teams.cpp:48:15: error: request for member 'empty' in 'pq', which is of non-class type 'int' while(!pq.empty() && pq.top().end < k[i] && ctr > 0){ ^~~~~ teams.cpp:48:29: error: request for member 'top' in 'pq', which is of non-class type 'int' while(!pq.empty() && pq.top().end < k[i] && ctr > 0){ ^~~ teams.cpp:49:10: error: request for member 'pop' in 'pq', which is of non-class type 'int' pq.pop(); ^~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from teams.cpp:1: /usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = info*; _Iterator2 = info*]': /usr/include/c++/7/bits/stl_algo.h:81:17: required from 'void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare) [with _Iterator = info*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/7/bits/stl_algo.h:1921:34: required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = info*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/7/bits/stl_algo.h:1953:38: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = info*; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/7/bits/stl_algo.h:1968:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = info*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/7/bits/stl_algo.h:4836:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = info*]' teams.cpp:38:17: required from here /usr/include/c++/7/bits/predefined_ops.h:43:23: error: no match for 'operator<' (operand types are 'info' and 'info') { return *__it1 < *__it2; } ~~~~~~~^~~~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from teams.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:888:5: note: candidate: template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&) operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:888:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from teams.cpp:1: /usr/include/c++/7/bits/predefined_ops.h:43:23: note: 'info' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' { return *__it1 < *__it2; } ~~~~~~~^~~~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from teams.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:895:5: note: candidate: template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_Iterator, _Containe