제출 #143042

#제출 시각아이디문제언어결과실행 시간메모리
143042nekiTeams (IOI15_teams)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define loop(i, a, b) for(long long i=a;i<b;i++) #define second se #define first fi #define maxn 200100 using namespace std; typedef long long ll; typedef pair<ll, ll> pii; int n, *a, *b; pii arr[maxn]; vector<int> tree[2*maxn]; int ch(int ta, int tb){ int ans=0, l=lower_bound(a, a+n, ta)-a, r=n; for(l+=n, r+=n;l<r;l>>=1, r>>=1){ if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++]; if(r&1) ans+=lower_bound(tree[--r].begin(), tree[r].end(), tb)-tree[r]; } return ans; } void init(int N, int A[], int B[]) { n=N;a=A;b=B loop(i, 0, n) arr={a, b};sort(arr, arr+n); sort(a, a+n);sort(b, b+n); loop(i, 0, n) for(int j=i+n;j>0;j>>=1) tree[j].push_back(arr[i].se); loop(i, 0, 2*n) sort(tree[i].begin(), tree[i].end()); } int can(int m, int k[]){ int c[m+1];loop(i, 0, m) c[i]=k[i];c[m]=0; m++;sort(c, c+m); int ints=0; loop(i, 1, m+1){ int st=lower_bound(a, a+n,c[i])-upper_bound(a, a+n,c[i-1]); int en=upper_bound(b, b+n,c[i])-lower_bound(b, b+n,c[i-1]); st, en-=ch(c[i-1]+1, c[i]-1); ints=max(ints-en, 0);ints+=st-c[i]; if(ints<0) return 0; } return 1; }

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

teams.cpp: In function 'int ch(int, int)':
teams.cpp:15:41: warning: conversion to 'int' from 'long int' may alter its value [-Wconversion]
     int ans=0, l=lower_bound(a, a+n, ta)-a, r=n;
                  ~~~~~~~~~~~~~~~~~~~~~~~^~
teams.cpp:17:69: error: no match for 'operator-' (operand types are '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' and 'std::vector<int>')
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
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/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from teams.cpp:1:
/usr/include/c++/7/bits/stl_iterator.h:840:7: note: candidate: __gnu_cxx::__normal_iterator<_Iterator, _Container> __gnu_cxx::__normal_iterator<_Iterator, _Container>::operator-(__gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type) const [with _Iterator = int*; _Container = std::vector<int>; __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type = long int]
       operator-(difference_type __n) const _GLIBCXX_NOEXCEPT
       ^~~~~~~~
/usr/include/c++/7/bits/stl_iterator.h:840:7: note:   no known conversion for argument 1 from 'std::vector<int>' to '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type {aka long int}'
/usr/include/c++/7/bits/stl_iterator.h:389:5: note: candidate: template<class _IteratorL, class _IteratorR> decltype ((__y.base() - __x.base())) 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:389:5: note:   template argument deduction/substitution failed:
teams.cpp:17:78: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::reverse_iterator<_Iterator>'
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                                                                              ^
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/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from teams.cpp:1:
/usr/include/c++/7/bits/stl_iterator.h:1191:5: note: candidate: template<class _IteratorL, class _IteratorR> decltype ((__x.base() - __y.base())) 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:1191:5: note:   template argument deduction/substitution failed:
teams.cpp:17:78: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::move_iterator<_IteratorL>'
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                                                                              ^
In file included from /usr/include/c++/7/ccomplex:39:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from teams.cpp:1:
/usr/include/c++/7/complex:356:5: note: candidate: template<class _Tp> std::complex<_Tp> std::operator-(const std::complex<_Tp>&, const std::complex<_Tp>&)
     operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
     ^~~~~~~~
/usr/include/c++/7/complex:356:5: note:   template argument deduction/substitution failed:
teams.cpp:17:78: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::complex<_Tp>'
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                                                                              ^
In file included from /usr/include/c++/7/ccomplex:39:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from teams.cpp:1:
/usr/include/c++/7/complex:365:5: note: candidate: template<class _Tp> std::complex<_Tp> std::operator-(const std::complex<_Tp>&, const _Tp&)
     operator-(const complex<_Tp>& __x, const _Tp& __y)
     ^~~~~~~~
/usr/include/c++/7/complex:365:5: note:   template argument deduction/substitution failed:
teams.cpp:17:78: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::complex<_Tp>'
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                                                                              ^
In file included from /usr/include/c++/7/ccomplex:39:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from teams.cpp:1:
/usr/include/c++/7/complex:374:5: note: candidate: template<class _Tp> std::complex<_Tp> std::operator-(const _Tp&, const std::complex<_Tp>&)
     operator-(const _Tp& __x, const complex<_Tp>& __y)
     ^~~~~~~~
/usr/include/c++/7/complex:374:5: note:   template argument deduction/substitution failed:
teams.cpp:17:78: note:   'std::vector<int>' is not derived from 'const std::complex<_Tp>'
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                                                                              ^
In file included from /usr/include/c++/7/ccomplex:39:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from teams.cpp:1:
/usr/include/c++/7/complex:451:5: note: candidate: template<class _Tp> std::complex<_Tp> std::operator-(const std::complex<_Tp>&)
     operator-(const complex<_Tp>& __x)
     ^~~~~~~~
/usr/include/c++/7/complex:451:5: note:   template argument deduction/substitution failed:
teams.cpp:17:78: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::complex<_Tp>'
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                                                                              ^
In file included from /usr/include/c++/7/deque:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:68,
                 from teams.cpp:1:
/usr/include/c++/7/bits/stl_deque.h:351:5: note: candidate: template<class _Tp, class _Ref, class _Ptr> typename std::_Deque_iterator<_Tp, _Ref, _Ptr>::difference_type 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:351:5: note:   template argument deduction/substitution failed:
teams.cpp:17:78: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::_Deque_iterator<_Tp, _Ref, _Ptr>'
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                                                                              ^
In file included from /usr/include/c++/7/deque:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:68,
                 from teams.cpp:1:
/usr/include/c++/7/bits/stl_deque.h:363:5: note: candidate: template<class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR> typename std::_Deque_iterator<_Tp, _Ref, _Ptr>::difference_type 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:363:5: note:   template argument deduction/substitution failed:
teams.cpp:17:78: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::_Deque_iterator<_Tp, _Ref, _Ptr>'
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                                                                              ^
In file included from /usr/include/c++/7/vector:65:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from teams.cpp:1:
/usr/include/c++/7/bits/stl_bvector.h:208:3: note: candidate: std::ptrdiff_t std::operator-(const std::_Bit_iterator_base&, const std::_Bit_iterator_base&)
   operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
   ^~~~~~~~
/usr/include/c++/7/bits/stl_bvector.h:208:3: note:   no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'const std::_Bit_iterator_base&'
In file included from /usr/include/c++/7/valarray:592:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95,
                 from teams.cpp:1:
/usr/include/c++/7/bits/valarray_after.h:403:5: note: candidate: template<class _Dom1, class _Dom2> std::_Expr<std::_BinClos<std::__minus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::_Expr<_Dom2, typename _Dom2::value_type>&)
     _DEFINE_EXPR_BINARY_OPERATOR(-, __minus)
     ^
/usr/include/c++/7/bits/valarray_after.h:403:5: note:   template argument deduction/substitution failed:
teams.cpp:17:78: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                                                                              ^
In file included from /usr/include/c++/7/valarray:592:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95,
                 from teams.cpp:1:
/usr/include/c++/7/bits/valarray_after.h:403:5: note: candidate: template<class _Dom> std::_Expr<std::_BinClos<std::__minus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)
     _DEFINE_EXPR_BINARY_OPERATOR(-, __minus)
     ^
/usr/include/c++/7/bits/valarray_after.h:403:5: note:   template argument deduction/substitution failed:
teams.cpp:17:78: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                                                                              ^
In file included from /usr/include/c++/7/valarray:592:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95,
                 from teams.cpp:1:
/usr/include/c++/7/bits/valarray_after.h:403:5: note: candidate: template<class _Dom> std::_Expr<std::_BinClos<std::__minus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const typename _Dom::value_type&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)
     _DEFINE_EXPR_BINARY_OPERATOR(-, __minus)
     ^
/usr/include/c++/7/bits/valarray_after.h:403:5: note:   template argument deduction/substitution failed:
teams.cpp:17:78: note:   'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                                                                              ^
In file included from /usr/include/c++/7/valarray:592:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95,
                 from teams.cpp:1:
/usr/include/c++/7/bits/valarray_after.h:403:5: note: candidate: template<class _Dom> std::_Expr<std::_BinClos<std::__minus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::valarray<typename _Dom::value_type>&)
     _DEFINE_EXPR_BINARY_OPERATOR(-, __minus)
     ^
/usr/include/c++/7/bits/valarray_after.h:403:5: note:   template argument deduction/substitution failed:
teams.cpp:17:78: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                                                                              ^
In file included from /usr/include/c++/7/valarray:592:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95,
                 from teams.cpp:1:
/usr/include/c++/7/bits/valarray_after.h:403:5: note: candidate: template<class _Dom> std::_Expr<std::_BinClos<std::__minus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const std::valarray<typename _Dom::value_type>&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)
     _DEFINE_EXPR_BINARY_OPERATOR(-, __minus)
     ^
/usr/include/c++/7/bits/valarray_after.h:403:5: note:   template argument deduction/substitution failed:
teams.cpp:17:78: note:   'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                                                                              ^
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0,
                 from teams.cpp:1:
/usr/include/c++/7/valarray:1173:1: note: candidate: template<class _Tp> std::_Expr<std::_BinClos<std::__minus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const std::valarray<_Tp>&, const std::valarray<_Tp>&)
 _DEFINE_BINARY_OPERATOR(-, __minus)
 ^
/usr/include/c++/7/valarray:1173:1: note:   template argument deduction/substitution failed:
teams.cpp:17:78: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::valarray<_Tp>'
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                                                                              ^
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0,
                 from teams.cpp:1:
/usr/include/c++/7/valarray:1173:1: note: candidate: template<class _Tp> std::_Expr<std::_BinClos<std::__minus, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const std::valarray<_Tp>&, const _Tp&)
 _DEFINE_BINARY_OPERATOR(-, __minus)
 ^
/usr/include/c++/7/valarray:1173:1: note:   template argument deduction/substitution failed:
teams.cpp:17:78: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::valarray<_Tp>'
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                                                                              ^
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0,
                 from teams.cpp:1:
/usr/include/c++/7/valarray:1173:1: note: candidate: template<class _Tp> std::_Expr<std::_BinClos<std::__minus, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const _Tp&, const std::valarray<_Tp>&)
 _DEFINE_BINARY_OPERATOR(-, __minus)
 ^
/usr/include/c++/7/valarray:1173:1: note:   template argument deduction/substitution failed:
teams.cpp:17:78: note:   'std::vector<int>' is not derived from 'const std::valarray<_Tp>'
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                                                                              ^
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/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from teams.cpp:1:
/usr/include/c++/7/bits/stl_iterator.h:962:5: note: candidate: template<class _Iterator, class _Container> typename __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type __gnu_cxx::operator-(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)
     operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/stl_iterator.h:962:5: note:   template argument deduction/substitution failed:
teams.cpp:17:78: note:   'std::vector<int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
         if(l&1) ans+=lower_bound(tree[l].begin(), tree[l].end(), tb)-tree[l++];
                                                                              ^
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/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from teams.cpp:1:
/usr/include/c++/7/bits/stl_iterator.h:950:5: note: candidate: template<class _IteratorL, class _IteratorR, class _Container> decltype ((__lhs.base() - __rhs.base())) __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:950:5: note:   template argument deduction/substitution failed:
/var/loca