Submission #558458

#TimeUsernameProblemLanguageResultExecution timeMemory
558458uroskHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
Compilation error
0 ms0 KiB
// __builtin_popcount(x) // __builtin_popcountll(x) #define here cerr<<"===========================================\n" #include <bits/stdc++.h> #define ld double #define ll short int #define ull unsigned long long #define llinf 100000000000000000LL // 10^17 #define iinf 2000000000 // 2*10^9 #define pb push_back #define popb pop_back #define fi first #define sc second #define endl '\n' #define pii pair<int,int> #define pll pair<ll,ll> #define pld pair<ld,ld> #define sz(a) int(a.size()) #define all(a) a.begin(),a.end() #define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;} using namespace std; #define maxn 1000005 ll n,q; ll a[maxn]; set<ll> t[4*maxn]; ll val[4*maxn]; ll mood; bool moe = 1; void init(ll v,ll tl,ll tr){ if(tl==tr){ t[v].insert(a[tl]); return; } ll mid = (tl+tr)/2; init(2*v,tl,mid); init(2*v+1,mid+1,tr); auto it = t[2*v].end(); it--; ll x = *it; it = t[2*v+1].lower_bound(x); if(it==t[2*v+1].begin()){ val[v] = 0; }else{ it--; val[v] = x + *it; } val[v] = max(val[v],max(val[2*v],val[2*v+1])); //here; //cerr<<tl<< " "<<tr<<" "<<val[v]<<" "<<*it<<endl; for(ll i = tl;i<=tr;i++) t[v].insert(a[i]); } set<ll> get(ll v,ll tl,ll tr,ll l,ll r){ if(l>r) return {}; if(tl==l&&tr==r){ if(val[v]>mood){ moe = 0; return {}; } return t[v]; } ll mid = (tl+tr)/2; set<ll> lf = get(2*v,tl,mid,l,min(mid,r)); set<ll> rf = get(2*v+1,mid+1,tr,max(mid+1,l),r); if(moe==0) return {}; if(sz(lf)==0) return rf; if(sz(rf)==0) return lf; auto it = lf.end(); it--; ll x = *it; it = rf.lower_bound(x); if(it==rf.begin()){ for(ll x : lf) rf.insert(x); return rf; } it--; if(x+*it>mood){ moe = 0; return {}; } for(ll x : lf) rf.insert(x); return rf; } int main(){ ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0); cin >> n >> q; for(ll i = 1;i<=n;i++) cin >> a[i]; init(1,1,n); while(q--){ ll l,r; cin >> l >> r >> mood; moe = 1; get(1,1,n,l,r); cout<<moe<<endl; } return 0; } /* 4 1 1 2 1 1 1 4 1 */

Compilation message (stderr)

sortbooks.cpp: In function 'std::set<short int> get(short int, short int, short int, short int, short int)':
sortbooks.cpp:62:48: error: no matching function for call to 'max(int, short int&)'
   62 |     set<ll> rf = get(2*v+1,mid+1,tr,max(mid+1,l),r);
      |                                                ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from sortbooks.cpp:4:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
sortbooks.cpp:62:48: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'short int')
   62 |     set<ll> rf = get(2*v+1,mid+1,tr,max(mid+1,l),r);
      |                                                ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from sortbooks.cpp:4:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
sortbooks.cpp:62:48: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'short int')
   62 |     set<ll> rf = get(2*v+1,mid+1,tr,max(mid+1,l),r);
      |                                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from sortbooks.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
sortbooks.cpp:62:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   62 |     set<ll> rf = get(2*v+1,mid+1,tr,max(mid+1,l),r);
      |                                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from sortbooks.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
sortbooks.cpp:62:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   62 |     set<ll> rf = get(2*v+1,mid+1,tr,max(mid+1,l),r);
      |                                                ^