Submission #499643

#TimeUsernameProblemLanguageResultExecution timeMemory
499643pragmatistSplit the sequence (APIO14_sequence)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define pb push_back #define sz(v) (int)v.size() #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define x first #define y second #define int long long #define nl "\n" using namespace std; typedef long long ll; typedef pair<long long, long long> pll; typedef pair <ll, ll> pii; const int N = (int)1e5 + 7; const int M = (int)7e6 + 7; const ll MOD = (ll)1e9 + 7; const int inf = (int)1e9 + 7; const ll INF = (ll)3e18 + 7; pii dir[] = {{-1, -1}, {1, 1}, {-1, 1}, {1, -1}}; int n, c, a[N], p[N], dp[201][201]; pii pr[201][201]; void solve() { cin >> n >> c; for(int i = 1; i <= n; ++i) { cin >> a[i]; p[i] = p[i - 1] + a[i]; } for(int i = 1; i <= n; ++i) { for(int k = 1; k <= min(c, i); ++k) { for(int j = 0; j < i; ++j) { int cur = dp[j][k-1] + (p[i] - p[j]) * (p[n] - p[i]); if(cur >= dp[i][k]) { dp[i][k] = cur; pr[i][k] = {j, k - 1}; } } } } int ans = 0, s = 0; for(int i = 1; i <= n; ++i) { if(dp[i][c] > ans) { ans = dp[i][c]; s = i; } } vector<int> v; for(int t = c; t >= 1; --t) { v.pb(s); s = pr[s][t].x; } reverse(all(s)); cout << ans << nl; for(auto x : v) cout << x << ' '; } signed main() { ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); int test = 1; //cin >> test; for(int i = 1; i <= test; ++i) { //cout << "Case " << i << ": "; solve(); } return 0; }

Compilation message (stderr)

sequence.cpp: In function 'void solve()':
sequence.cpp:5:18: error: request for member 'begin' in 's', which is of non-class type 'long long int'
    5 | #define all(v) v.begin(),v.end()
      |                  ^~~~~
sequence.cpp:58:10: note: in expansion of macro 'all'
   58 |  reverse(all(s));
      |          ^~~
sequence.cpp:5:28: error: request for member 'end' in 's', which is of non-class type 'long long int'
    5 | #define all(v) v.begin(),v.end()
      |                            ^~~
sequence.cpp:58:10: note: in expansion of macro 'all'
   58 |  reverse(all(s));
      |          ^~~