Submission #1133435

#TimeUsernameProblemLanguageResultExecution timeMemory
1133435vladiliusChase (CEOI17_chase)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
const ll inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n, k; cin>>n>>k;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++){
        cin>>a[i];
    }
    vector<int> g[n + 1];
    for (int i = 1; i < n; i++){
        int x, y; cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    vector<ll> s(n + 1);
    for (int i = 1; i <= n; i++){
        s[i] = a[i];
        for (int j: g[i]){
            s[i] += a[j];
        }
    }
    
    ll dp[n + 1][k + 1][3];
    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= k; j++){
            dp[i][j][0] = dp[i][j][1] = dp[i][j][2] = 0;
        }
    }
    ll out = 0;
    function<void(int, int)> fill = [&](int v, int pr){
        for (int i: g[v]){
            if (i == pr) continue;
            fill(i, v);
        }
        dp[v][0][0] = dp[v][0][1] = dp[v][0][2] = 0;
        for (int x = 1; x <= k; x++){
            dp[v][x][0] = dp[v][x][1] = dp[v][x][2] = -inf; 
            for (int i: g[v]){
                if (i == pr) continue;
                dp[v][x][0] = max(dp[v][x][0], s[v] + dp[i][x - 1][0] - a[v] - a[v]);
                dp[v][x][0] = max(dp[v][x][0], s[v] + dp[i][x - 1][1] - a[i] - a[v]);
                dp[v][x][0] = max(dp[v][x][0], s[v] + dp[i][x - 1][2] - a[v]);
                
                dp[v][x][1] = max(dp[v][x][1], dp[i][x][0] - a[v]);
                
                dp[v][x][2] = max(dp[v][x][2], dp[i][x][1] - a[v]);
                dp[v][x][2] = max(dp[v][x][2], dp[i][x][2] - a[v]);
            }
            out = max(out, dp[v][x][0]);
            out = max(out, dp[v][x][1]);
            out = max(out, dp[v][x][2]);
        }
    };
    
    for (int i = 1; i <= n; i++) fill(i, 0);
    
    cout<<out<<"\n";
}

Compilation message (stderr)

chase.cpp: In lambda function:
chase.cpp:46:9: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   46 |         dp[v][0][0] = dp[v][0][1] = dp[v][0][2] = 0;
      |         ^~
chase.cpp:46:9: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:46:23: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   46 |         dp[v][0][0] = dp[v][0][1] = dp[v][0][2] = 0;
      |                       ^~
chase.cpp:46:23: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:46:37: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   46 |         dp[v][0][0] = dp[v][0][1] = dp[v][0][2] = 0;
      |                                     ^~
chase.cpp:46:37: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:48:13: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   48 |             dp[v][x][0] = dp[v][x][1] = dp[v][x][2] = -inf;
      |             ^~
chase.cpp:48:13: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:48:27: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   48 |             dp[v][x][0] = dp[v][x][1] = dp[v][x][2] = -inf;
      |                           ^~
chase.cpp:48:27: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:48:41: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   48 |             dp[v][x][0] = dp[v][x][1] = dp[v][x][2] = -inf;
      |                                         ^~
chase.cpp:48:41: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:51:17: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   51 |                 dp[v][x][0] = max(dp[v][x][0], s[v] + dp[i][x - 1][0] - a[v] - a[v]);
      |                 ^~
chase.cpp:51:17: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:51:35: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   51 |                 dp[v][x][0] = max(dp[v][x][0], s[v] + dp[i][x - 1][0] - a[v] - a[v]);
      |                                   ^~
chase.cpp:51:35: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:51:55: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   51 |                 dp[v][x][0] = max(dp[v][x][0], s[v] + dp[i][x - 1][0] - a[v] - a[v]);
      |                                                       ^~
chase.cpp:51:55: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:52:17: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   52 |                 dp[v][x][0] = max(dp[v][x][0], s[v] + dp[i][x - 1][1] - a[i] - a[v]);
      |                 ^~
chase.cpp:52:17: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:52:35: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   52 |                 dp[v][x][0] = max(dp[v][x][0], s[v] + dp[i][x - 1][1] - a[i] - a[v]);
      |                                   ^~
chase.cpp:52:35: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:52:55: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   52 |                 dp[v][x][0] = max(dp[v][x][0], s[v] + dp[i][x - 1][1] - a[i] - a[v]);
      |                                                       ^~
chase.cpp:52:55: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:53:17: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   53 |                 dp[v][x][0] = max(dp[v][x][0], s[v] + dp[i][x - 1][2] - a[v]);
      |                 ^~
chase.cpp:53:17: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:53:35: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   53 |                 dp[v][x][0] = max(dp[v][x][0], s[v] + dp[i][x - 1][2] - a[v]);
      |                                   ^~
chase.cpp:53:35: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:53:55: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   53 |                 dp[v][x][0] = max(dp[v][x][0], s[v] + dp[i][x - 1][2] - a[v]);
      |                                                       ^~
chase.cpp:53:55: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:55:17: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   55 |                 dp[v][x][1] = max(dp[v][x][1], dp[i][x][0] - a[v]);
      |                 ^~
chase.cpp:55:17: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:55:35: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   55 |                 dp[v][x][1] = max(dp[v][x][1], dp[i][x][0] - a[v]);
      |                                   ^~
chase.cpp:55:35: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:55:48: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   55 |                 dp[v][x][1] = max(dp[v][x][1], dp[i][x][0] - a[v]);
      |                                                ^~
chase.cpp:55:48: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:57:17: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   57 |                 dp[v][x][2] = max(dp[v][x][2], dp[i][x][1] - a[v]);
      |                 ^~
chase.cpp:57:17: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:57:35: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   57 |                 dp[v][x][2] = max(dp[v][x][2], dp[i][x][1] - a[v]);
      |                                   ^~
chase.cpp:57:35: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:57:48: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   57 |                 dp[v][x][2] = max(dp[v][x][2], dp[i][x][1] - a[v]);
      |                                                ^~
chase.cpp:57:48: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:58:17: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   58 |                 dp[v][x][2] = max(dp[v][x][2], dp[i][x][2] - a[v]);
      |                 ^~
chase.cpp:58:17: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:58:35: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   58 |                 dp[v][x][2] = max(dp[v][x][2], dp[i][x][2] - a[v]);
      |                                   ^~
chase.cpp:58:35: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:58:48: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   58 |                 dp[v][x][2] = max(dp[v][x][2], dp[i][x][2] - a[v]);
      |                                                ^~
chase.cpp:58:48: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:60:28: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   60 |             out = max(out, dp[v][x][0]);
      |                            ^~
chase.cpp:60:28: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:61:28: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   61 |             out = max(out, dp[v][x][1]);
      |                            ^~
chase.cpp:61:28: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size
chase.cpp:62:28: sorry, unimplemented: capture of variably-modified type 'll [(n + 1)][(k + 1)][3]' {aka 'long long int [(n + 1)][(k + 1)][3]'} that is not an N3639 array of runtime bound
   62 |             out = max(out, dp[v][x][2]);
      |                            ^~
chase.cpp:62:28: note: because the array element type 'll [(k + 1)][3]' {aka 'long long int [(k + 1)][3]'} has variable size