Submission #467836

#TimeUsernameProblemLanguageResultExecution timeMemory
467836nickmet2004Election (BOI18_election)C++11
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; const int N = 5e5 + 5; int n , a[N]; string s; struct Node{ int L , R , cnt , ans; Node operator+(Node y){ Node ret; ret.cnt = cnt + y.cnt; ret.L = max(L + cnt + y.L); ret.R = max(y.R , y.cnt + R); ret.ans = max({ans + y.cnt , y.ans + cnt , L + y.R}); return ret; } }T[4*N]; void B(int l = 0 , int r = n - 1 , int pos = 0){ if(l == r){ if(a[l] == 1) T[pos] = {1 , 1, 1, 1}; else T[pos] = {0 , 0 , -1 , 0}; return; } int mid = (l + r) >> 1; B(l , mid , pos * 2 + 1); B(mid + 1 ,r , pos * 2 + 2); T[pos] = T[pos *2 + 1] + T[pos *2 + 2]; } Node get(int L , int R , int l =0 , int r = n - 1 , int pos = 0){ if(r <L || R < l) return {0 , 0 , 0 , 0}; if(L <= l && r <= R) return T[pos]; int mid = (l + r) >> 1; return get(L , R , l , mid , pos * 2 + 1) + get(L , R , mid + 1 , r , pos * 2 + 2); } int main (){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> s; memset(a , -1 , sizeof(a)); for(int i = 0;i < n; ++i){ if(s[i] == 'T')a[i] = 1; } B(); int q; cin >> q; while(q--){ int a , b; cin >> a >> b; --a; --b; cout << get(a , b).ans << endl; } }

Compilation message (stderr)

election.cpp: In member function 'Node Node::operator+(Node)':
election.cpp:12:34: error: no matching function for call to 'max(int)'
   12 |         ret.L = max(L + cnt + y.L);
      |                                  ^
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 election.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> 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:
election.cpp:12:34: note:   candidate expects 2 arguments, 1 provided
   12 |         ret.L = max(L + cnt + y.L);
      |                                  ^
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 election.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> 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:
election.cpp:12:34: note:   candidate expects 3 arguments, 1 provided
   12 |         ret.L = max(L + cnt + y.L);
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from election.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> _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:
election.cpp:12:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   12 |         ret.L = max(L + cnt + y.L);
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from election.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> _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:
election.cpp:12:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   12 |         ret.L = max(L + cnt + y.L);
      |                                  ^