QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#31175#2573. Two Permutationsleeh18WA 3ms7768kbC++201.3kb2022-05-04 02:49:482022-05-04 02:49:50

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-04 02:49:50]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:7768kb
  • [2022-05-04 02:49:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int mod = 1000000007;
int dp[2][101][10001];

int main() {
    cin.tie(0)->sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            for (int k = 0; k <= m; k++) {
                if (n-2*i+j+2 >= 2) {
                    dp[i&1][j][k] += (long long)dp[(i&1)^1][j][k] * (n-2*i+j+2) * (n-2*i+j+1) % mod;
                    if (dp[i&1][j][k] >= mod) {
                        dp[i&1][j][k] -= mod;
                    }
                }
                if (j >= 1 && k >= i && (n-2*i+j+1) >= 0) {
                    dp[i&1][j][k] += (long long)dp[(i&1)^1][j-1][k-i] * (n-2*i+j+1) * (2*i-2*j+1) % mod;
                    if (dp[i&1][j][k] >= mod) {
                        dp[i&1][j][k] -= mod;
                    }
                }
                if (j >= 2 && k >= 2*i && i-j+1 >= 0) {
                    dp[i&1][j][k] += (long long)dp[(i&1)^1][j-2][k-2*i] * (i-j+1) * (i-j+1) % mod;
                    if (dp[i&1][j][k] >= mod) {
                        dp[i&1][j][k] -= mod;
                    }
                }
            }
        }
    }
    cout << dp[n&1][n][m] << '\n';
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 7768kb

input:

2 4

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 3ms
memory: 5520kb

input:

3 7

output:

12

result:

ok 1 number(s): "12"

Test #3:

score: 0
Accepted
time: 3ms
memory: 5636kb

input:

4 10

output:

24

result:

ok 1 number(s): "24"

Test #4:

score: -100
Wrong Answer
time: 2ms
memory: 5728kb

input:

4 14

output:

100

result:

wrong answer 1st numbers differ - expected: '96', found: '100'