QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#780824#7988. 史莱姆工厂hhoppitreeCompile Error//C++173.6kb2024-11-25 13:28:272024-11-25 13:28:28

Judging History

你现在查看的是最新测评结果

  • [2024-11-25 13:28:28]
  • 评测
  • [2024-11-25 13:28:27]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 155, M = 15;

int c[N], w[N], p[N];
long long f[N][N], fl[N][N][M], fr[N][N][M];

void upd(long long &x, long long y) {
    (y > x) && (x = y);
}

signed main() {
    int n, m, t; scanf("%d%d%d", &n, &m, &t);
    for (int i = 1; i <= n; ++i) scanf("%d", &c[i]);
    for (int i = 1; i <= n; ++i) scanf("%d", &w[i]);
    for (int i = m; i <= m * 2 - 2; ++i) scanf("%d", &p[i]);
    for (int i = m - 1; i; --i) p[i] = p[i + 1] - t;
    memset(f, -0x3f, sizeof(f)), memset(fl, -0x3f, sizeof(f)), memset(fr, -0x3f, sizeof(f));
    for (int i = 1; i <= n + 1; ++i) fl[i][i][w[i]] = fr[i][i][w[i]] = f[i][i - 1] = 0, f[i][i] = p[w[i]];
    for (int l = n; l >= 1; --l) {
        for (int r = l + 1; r <= n; ++r) {
            fl[l][r][w[l]] = f[l + 1][r];
            for (int i = l + 1; i <= r; ++i) {
                if (c[i] != c[l]) continue;
                for (int j = 1; j + w[l] < m; ++j) upd(fl[l][r][j + w[l]], fl[i][r][j] + f[l + 1][i - 1]);
            }
            fr[l][r][w[r]] = f[l][r - 1];
            for (int i = l; i <= r - 1; ++i) {
                if (c[i] != c[r]) continue;
                for (int j = 1; j + w[r] < m; ++j) upd(fr[l][r][j + w[r]], fr[l][i][j] + f[i + 1][r - 1]);
            }
            for (int i = l; i < r; ++i) {
                if (c[l - 1] != c[i + 1] && c[r + 1] != c[i]) upd(f[l][r], f[l][i] + f[i + 1][r]);
            }
            if (c[l] != c[r]) continue;
            for (int i = l; i < r; ++i) {
                for (int j = 1; j < m; ++j) {
                    for (int k = 1; k < m; ++k) {
                        upd(f[l][r], fl[l][i][j] + fr[i + 1][r][k] + p[j + k]);
                    }
                }
            }
        }
    }
    printf("%lld\n", f[1][n]);
    return 0;
}#include <bits/stdc++.h>

using namespace std;

const int N = 155, M = 15;

int c[N], w[N], p[N];
long long f[N][N], fl[N][N][M], fr[N][N][M];

void upd(long long &x, long long y) {
    (y > x) && (x = y);
}

signed main() {
    int n, m, t; scanf("%d%d%d", &n, &m, &t);
    for (int i = 1; i <= n; ++i) scanf("%d", &c[i]);
    for (int i = 1; i <= n; ++i) scanf("%d", &w[i]);
    for (int i = m; i <= m * 2 - 2; ++i) scanf("%d", &p[i]);
    for (int i = m - 1; i; --i) p[i] = p[i + 1] - t;
    memset(f, -0x3f, sizeof(f)), memset(fl, -0x3f, sizeof(f)), memset(fr, -0x3f, sizeof(f));
    for (int i = 1; i <= n; ++i) fl[i][i][w[i]] = fr[i][i][w[i]] = f[i][i - 1] = 0, f[i][i] = p[w[i]];
    for (int l = n; l >= 1; --l) {
        for (int r = l + 1; r <= n; ++r) {
            fl[l][r][w[l]] = f[l + 1][r];
            for (int i = l + 1; i <= r; ++i) {
                if (c[i] != c[l]) continue;
                for (int j = 1; j + w[l] < m; ++j) upd(fl[l][r][j + w[l]], fl[i][r][j] + f[l + 1][i - 1]);
            }
            fr[l][r][w[r]] = f[l][r - 1];
            for (int i = l; i <= r - 1; ++i) {
                if (c[i] != c[r]) continue;
                for (int j = 1; j + w[r] < m; ++j) upd(fr[l][r][j + w[r]], fr[l][i][j] + f[i + 1][r - 1]);
            }
            for (int i = l; i < r; ++i) {
                if (c[l - 1] != c[i + 1] || c[r + 1] != c[i]) upd(f[l][r], f[l][i] + f[i + 1][r]);
            }
            if (c[l] != c[r]) continue;
            for (int i = l; i < r; ++i) {
                for (int j = 1; j < m; ++j) {
                    for (int k = 1; k < m; ++k) {
                        upd(f[l][r], fl[l][i][j] + fr[i + 1][r][k] + p[j + k]);
                    }
                }
            }
        }
    }
    printf("%lld\n", f[1][n]);
    return 0;
}

Details

answer.code:49:2: error: stray ‘#’ in program
   49 | }#include <bits/stdc++.h>
      |  ^
answer.code:49:3: error: ‘include’ does not name a type
   49 | }#include <bits/stdc++.h>
      |   ^~~~~~~
answer.code:53:11: error: redefinition of ‘const int N’
   53 | const int N = 155, M = 15;
      |           ^
answer.code:5:11: note: ‘const int N’ previously defined here
    5 | const int N = 155, M = 15;
      |           ^
answer.code:53:20: error: redefinition of ‘const int M’
   53 | const int N = 155, M = 15;
      |                    ^
answer.code:5:20: note: ‘const int M’ previously defined here
    5 | const int N = 155, M = 15;
      |                    ^
answer.code:55:5: error: redefinition of ‘int c [155]’
   55 | int c[N], w[N], p[N];
      |     ^
answer.code:7:5: note: ‘int c [155]’ previously declared here
    7 | int c[N], w[N], p[N];
      |     ^
answer.code:55:11: error: redefinition of ‘int w [155]’
   55 | int c[N], w[N], p[N];
      |           ^
answer.code:7:11: note: ‘int w [155]’ previously declared here
    7 | int c[N], w[N], p[N];
      |           ^
answer.code:55:17: error: redefinition of ‘int p [155]’
   55 | int c[N], w[N], p[N];
      |                 ^
answer.code:7:17: note: ‘int p [155]’ previously declared here
    7 | int c[N], w[N], p[N];
      |                 ^
answer.code:56:11: error: redefinition of ‘long long int f [155][155]’
   56 | long long f[N][N], fl[N][N][M], fr[N][N][M];
      |           ^
answer.code:8:11: note: ‘long long int f [155][155]’ previously declared here
    8 | long long f[N][N], fl[N][N][M], fr[N][N][M];
      |           ^
answer.code:56:20: error: redefinition of ‘long long int fl [155][155][15]’
   56 | long long f[N][N], fl[N][N][M], fr[N][N][M];
      |                    ^~
answer.code:8:20: note: ‘long long int fl [155][155][15]’ previously declared here
    8 | long long f[N][N], fl[N][N][M], fr[N][N][M];
      |                    ^~
answer.code:56:33: error: redefinition of ‘long long int fr [155][155][15]’
   56 | long long f[N][N], fl[N][N][M], fr[N][N][M];
      |                                 ^~
answer.code:8:33: note: ‘long long int fr [155][155][15]’ previously declared here
    8 | long long f[N][N], fl[N][N][M], fr[N][N][M];
      |                                 ^~
answer.code:58:6: error: redefinition of ‘void upd(long long int&, long long int)’
   58 | void upd(long long &x, long long y) {
      |      ^~~
answer.code:10:6: note: ‘void upd(long long int&, long long int)’ previously defined here
   10 | void upd(long long &x, long long y) {
      |      ^~~
answer.code:62:8: error: redefinition of ‘int main()’
   62 | signed main() {
      |        ^~~~
answer.code:14:8: note: ‘int main()’ previously defined here
   14 | signed main() {
      |        ^~~~
answer.code: In function ‘int main()’:
answer.code:15:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |     int n, m, t; scanf("%d%d%d", &n, &m, &t);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
answer.code:16:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |     for (int i = 1; i <= n; ++i) scanf("%d", &c[i]);
      |                                  ~~~~~^~~~~~~~~~~~~
answer.code:17:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |     for (int i = 1; i <= n; ++i) scanf("%d", &w[i]);
      |                                  ~~~~~^~~~~~~~~~~~~
answer.code:18:47: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |     for (int i = m; i <= m * 2 - 2; ++i) scanf("%d", &p[i]);
      |                                          ~~~~~^~~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:63:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   63 |     int n, m, t; scanf("%d%d%d", &n, &m, &t);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
answer.code:64:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   64 |     for (int i = 1; i <= n; ++i) scanf("%d", &c[i]);
      |                                  ~~~~~^~~~~~~~~~~~~
answer.code:65:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   65 |     for (int i = 1; i <= n; ++i) scanf("%d", &w[i]);
      |                                  ~~~~~^~~~~~~~~~~~~
answer.code:66:47: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   66 |     for (int i = m; i <= m * 2 - 2; ++i) scanf("%d", &p[i]);
      |                                          ...