Submission #825523

#TimeUsernameProblemLanguageResultExecution timeMemory
825523boyliguanhanElection (BOI18_election)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; struct data { int l, r, s, a; data() : l(0),r(0),s(0),a(0){} data(bool b) : l(b), r(b), s(b?1:-1), a(b){} data(data a, data b) : l(max(a.l, a.s+b.l)), r(max(b.r,b.s+a.r)), s(a.s+b.s), a(max(max(a.a+b.s, b.a+a.s), a.l+b.r)){} }; vector<vector<data>> tb(500100, vector<data>(20)); int main() { int n, q; string str; cin >> n >> str >> q; for(int i = 1; i <= n; i++) { tb[i][0] = data(str[i-1]=='T'); } for(int j = 1; j < 20; j++) for(int i = 1; i < n-(1<<j)+2; i++) tb[i][j] = data(tb[i][j-1], tb[i+(1<<j-1)][j-1]); while(q--){ data d; int a, b; cin >> a >> b; for(int i = 20;i--;) if(a+(1<<i)-2<b) d = data(d,tb[a][i]), a+=(1<<i); cout << d.a << '\n'; } }

Compilation message (stderr)

election.cpp:9:15: error: template argument 1 is invalid
    9 | vector<vector<data>> tb(500100, vector<data>(20));
      |               ^~~~
election.cpp:9:15: error: template argument 2 is invalid
election.cpp:9:19: error: template argument 1 is invalid
    9 | vector<vector<data>> tb(500100, vector<data>(20));
      |                   ^~
election.cpp:9:19: error: template argument 2 is invalid
election.cpp:9:44: error: template argument 1 is invalid
    9 | vector<vector<data>> tb(500100, vector<data>(20));
      |                                            ^
election.cpp:9:44: error: template argument 2 is invalid
election.cpp:9:49: error: expression list treated as compound expression in initializer [-fpermissive]
    9 | vector<vector<data>> tb(500100, vector<data>(20));
      |                                                 ^
election.cpp: In function 'int main()':
election.cpp:15:11: error: invalid types 'int[int]' for array subscript
   15 |         tb[i][0] = data(str[i-1]=='T');
      |           ^
election.cpp:15:20: error: reference to 'data' is ambiguous
   15 |         tb[i][0] = data(str[i-1]=='T');
      |                    ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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/range_access.h:319:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)'
  319 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:310:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  310 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:300:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  300 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:290:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  290 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
election.cpp:3:8: note:                 'struct data'
    3 | struct data {
      |        ^~~~
election.cpp:19:15: error: invalid types 'int[int]' for array subscript
   19 |             tb[i][j] = data(tb[i][j-1], tb[i+(1<<j-1)][j-1]);
      |               ^
election.cpp:19:24: error: reference to 'data' is ambiguous
   19 |             tb[i][j] = data(tb[i][j-1], tb[i+(1<<j-1)][j-1]);
      |                        ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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/range_access.h:319:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)'
  319 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:310:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  310 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:300:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  300 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:290:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  290 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
election.cpp:3:8: note:                 'struct data'
    3 | struct data {
      |        ^~~~
election.cpp:19:31: error: invalid types 'int[int]' for array subscript
   19 |             tb[i][j] = data(tb[i][j-1], tb[i+(1<<j-1)][j-1]);
      |                               ^
election.cpp:19:51: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   19 |             tb[i][j] = data(tb[i][j-1], tb[i+(1<<j-1)][j-1]);
      |                                                  ~^~
election.cpp:19:43: error: invalid types 'int[int]' for array subscript
   19 |             tb[i][j] = data(tb[i][j-1], tb[i+(1<<j-1)][j-1]);
      |                                           ^
election.cpp:21:9: error: reference to 'data' is ambiguous
   21 |         data d;
      |         ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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/range_access.h:319:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)'
  319 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:310:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  310 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:300:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  300 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:290:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  290 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
election.cpp:3:8: note:                 'struct data'
    3 | struct data {
      |        ^~~~
election.cpp:26:17: error: 'd' was not declared in this scope
   26 |                 d = data(d,tb[a][i]), a+=(1<<i);
      |                 ^
election.cpp:26:21: error: reference to 'data' is ambiguous
   26 |                 d = data(d,tb[a][i]), a+=(1<<i);
      |                     ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 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/range_access.h:319:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)'
  319 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:310:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  310 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:300:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  300 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:290:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  290 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
election.cpp:3:8: note:                 'struct data'
    3 | struct data {
      |        ^~~~
election.cpp:26:30: error: invalid types 'int[int]' for array subscript
   26 |                 d = data(d,tb[a][i]), a+=(1<<i);
      |                              ^
election.cpp:27:17: error: 'd' was not declared in this scope
   27 |         cout << d.a << '\n';
      |                 ^