Submission #443548

#TimeUsernameProblemLanguageResultExecution timeMemory
443548prvocisloTeams (CEOI11_tea)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; struct kid { int a, i; }; bool cmp(const kid &a, const kid &b) { return a.a > b.a; } struct data { int cnt, mini, pv; }; void upd(data &a, const data &b) { if (b.cnt > a.cnt || (a.cnt == b.cnt && a.mini > b.mini)) a = b; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<kid> v(n+1); for (int i = 1; i <= n; i++) cin >> v[i].a, v[i].i = i; sort(v.begin()+1, v.end(), cmp); vector<data> dp(n+1); vector<vector<int> > vj(2*n+5); dp[v[1].a] = { 1, v[1].a, 0 }; for (int i = v[1].a+1; i <= n; i++) { dp[i] = { dp[i-1].cnt, dp[i-1].mini, dp[i-1].pv }; if (dp[i-1].mini * 1ll * dp[i-1].cnt == (ll)i) dp[i].mini++; for (int j : vj[i+1]) upd(dp[i], { dp[j-1].cnt+1, max(dp[j-1].mini, i-j+1), j-1 }); vj[v[i].a + i].push_back(i); } cout << dp[n].cnt << "\n"; int r = n; while (r) { //cout << r << endl; int l = dp[r].pv; cout << r - l; for (int i = l+1; i <= r; i++) cout << " " << v[i].i; cout << "\n"; r = l; } return 0; }

Compilation message (stderr)

tea.cpp:8:6: error: variable or field 'upd' declared void
    8 | void upd(data &a, const data &b)
      |      ^~~
tea.cpp:8:10: error: reference to 'data' is ambiguous
    8 | void upd(data &a, const data &b)
      |          ^~~~
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 tea.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()))
      |     ^~~~
tea.cpp:7:8: note:                 'struct data'
    7 | struct data { int cnt, mini, pv; };
      |        ^~~~
tea.cpp:8:16: error: 'a' was not declared in this scope
    8 | void upd(data &a, const data &b)
      |                ^
tea.cpp:8:19: error: expected primary-expression before 'const'
    8 | void upd(data &a, const data &b)
      |                   ^~~~~
tea.cpp: In function 'int main()':
tea.cpp:22:16: error: template argument 1 is invalid
   22 |     vector<data> dp(n+1);
      |                ^
tea.cpp:22:16: error: template argument 2 is invalid
tea.cpp:24:7: error: invalid types 'int[int]' for array subscript
   24 |     dp[v[1].a] = { 1, v[1].a, 0 };
      |       ^
tea.cpp:27:11: error: invalid types 'int[int]' for array subscript
   27 |         dp[i] = { dp[i-1].cnt, dp[i-1].mini, dp[i-1].pv };
      |           ^
tea.cpp:27:21: error: invalid types 'int[int]' for array subscript
   27 |         dp[i] = { dp[i-1].cnt, dp[i-1].mini, dp[i-1].pv };
      |                     ^
tea.cpp:27:34: error: invalid types 'int[int]' for array subscript
   27 |         dp[i] = { dp[i-1].cnt, dp[i-1].mini, dp[i-1].pv };
      |                                  ^
tea.cpp:27:48: error: invalid types 'int[int]' for array subscript
   27 |         dp[i] = { dp[i-1].cnt, dp[i-1].mini, dp[i-1].pv };
      |                                                ^
tea.cpp:28:15: error: invalid types 'int[int]' for array subscript
   28 |         if (dp[i-1].mini * 1ll * dp[i-1].cnt == (ll)i) dp[i].mini++;
      |               ^
tea.cpp:28:36: error: invalid types 'int[int]' for array subscript
   28 |         if (dp[i-1].mini * 1ll * dp[i-1].cnt == (ll)i) dp[i].mini++;
      |                                    ^
tea.cpp:28:58: error: invalid types 'int[int]' for array subscript
   28 |         if (dp[i-1].mini * 1ll * dp[i-1].cnt == (ll)i) dp[i].mini++;
      |                                                          ^
tea.cpp:30:19: error: invalid types 'int[int]' for array subscript
   30 |             upd(dp[i], { dp[j-1].cnt+1, max(dp[j-1].mini, i-j+1), j-1 });
      |                   ^
tea.cpp:30:28: error: invalid types 'int[int]' for array subscript
   30 |             upd(dp[i], { dp[j-1].cnt+1, max(dp[j-1].mini, i-j+1), j-1 });
      |                            ^
tea.cpp:30:47: error: invalid types 'int[int]' for array subscript
   30 |             upd(dp[i], { dp[j-1].cnt+1, max(dp[j-1].mini, i-j+1), j-1 });
      |                                               ^
tea.cpp:30:13: error: 'upd' was not declared in this scope
   30 |             upd(dp[i], { dp[j-1].cnt+1, max(dp[j-1].mini, i-j+1), j-1 });
      |             ^~~
tea.cpp:33:15: error: invalid types 'int[int]' for array subscript
   33 |     cout << dp[n].cnt << "\n";
      |               ^
tea.cpp:38:19: error: invalid types 'int[int]' for array subscript
   38 |         int l = dp[r].pv;
      |                   ^