QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#202941#2482. Storage Problemssalvator_noster#WA 1ms5748kbC++141.5kb2023-10-06 14:14:592023-10-06 14:15:00

Judging History

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

  • [2023-10-06 14:15:00]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5748kb
  • [2023-10-06 14:14:59]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int SIZE = 400 + 5;
const ll MOD = 167772161;

int n, m;
int wi[SIZE];
ll dp[SIZE][SIZE], tmp[SIZE][SIZE];

void add(ll &a, ll b) {
    a = (a + b) % MOD;
    return;
}

int main(void) {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &wi[i]);
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = i - 1; j >= 0; --j) {
            for (int k = 0; k <= m - wi[i]; ++k) {
                add(dp[j + 1][k + wi[i]], dp[j][k]);
            }
        }
    }
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            printf("%lld%c", dp[i][j], " \n"[j == m]);
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            memcpy(tmp[j], dp[j], (m + 1) * sizeof dp[j][0]);
        }
        for (int j = 1; j <= n; ++j) {
            for (int k = wi[i]; k <= m; ++k) {
                add(tmp[j][k], MOD - tmp[j - 1][k - wi[i]]);
            }
        }
        // for (int i = 0; i <= n; ++i) {
        //     for (int j = 0; j <= m; ++j) {
        //         printf("%lld%c", tmp[i][j], " \n"[j == m]);
        //     }
        // }
        for (int j = 1; j <= n - 1; ++j) {
            ll ans = 0;
            for (int k = m - wi[i] + 1; k <= m; ++k) {
                add(ans, tmp[j][k]);
            }
            printf("%lld%c", ans, " \n"[j == n - 1]);
        }
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5748kb

input:

3 2
1 1 2

output:

1 0 0
0 2 1
0 0 1
0 0 0
1 0
1 0
2 1

result:

wrong answer 1st lines differ - expected: '1 0', found: '1 0 0'