Submission #984577

#TimeUsernameProblemLanguageResultExecution timeMemory
984577DP_196Visiting Singapore (NOI20_visitingsingapore)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = 1005; int n, m, k, A, B; int f[MAXN][MAXN][2][2], v[MAXN], s[MAXN], t[MAXN]; int main() { //freopen("funtour.inp", "r", stdin); //freopen("funtour.out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); cin >> k >> n >> m >> A >> B; for (int i = 1; i <= k; i++) cin >> v[i]; for (int i = 1; i <= n; i++) cin >> s[i]; for (int i = 1; i <= m; i++) cin >> t[i]; memset(f, -0x3f, sizeof (f)); int res = -1e9; for (int i = 0; i <= m; i++) { f[0][i][0][1] = a + m * b; dp[0][i][0][0] = a + m * b; } f[0][0][0][0] = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { f[i][j][0][0] = max({ f[i - 1][j][0][0], f[i][j - 1][0][0], }) + B; f[i][j][0][0] = max(f[i][j][0][0], f[i - 1][i - 1][1][1] + 2 * B); f[i][j][0][1] = max(f[i - 1][j][0][1], f[i - 1][j][1][1]) + B; f[i][j][1][0] = max(f[i][j - 1][1][0], f[i][j - 1][1][1]) + B; if (s[i] == t[j]) { f[i][j][1][1] = max(f[i][j][1][1], (j > 1 ? A : 0) + (j - 1) * B + v[s[i]]); f[i][j][1][1] = max(f[i][j][1][1], f[i - 1][j - 1][0][0] + 2 * A + v[s[i]]); f[i][j][1][1] = max(f[i][j][1][1], f[i - 1][j - 1][0][1] + A + v[s[i]]); f[i][j][1][1] = max(f[i][j][1][1], f[i - 1][j - 1][1][0] + A + v[s[i]]); f[i][j][1][1] = max(f[i][j][1][1], f[i - 1][j - 1][1][1] + v[s[i]]); } res = max(res, f[i][j][1][1] + (m - j) * B + (j != m ? A : 0)); } } cout << res; }

Compilation message (stderr)

VisitingSingapore.cpp: In function 'int main()':
VisitingSingapore.cpp:29:19: error: 'a' was not declared in this scope
   29 |   f[0][i][0][1] = a + m * b;
      |                   ^
VisitingSingapore.cpp:29:27: error: 'b' was not declared in this scope
   29 |   f[0][i][0][1] = a + m * b;
      |                           ^
VisitingSingapore.cpp:30:3: error: 'dp' was not declared in this scope
   30 |   dp[0][i][0][0] = a + m * b;
      |   ^~