QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#31175 | #2573. Two Permutations | leeh18 | WA | 3ms | 7768kb | C++20 | 1.3kb | 2022-05-04 02:49:48 | 2022-05-04 02:49:50 |
Judging History
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'