5022 | 2023-04-09 22:04:26 | zsombor | Misztikus táblázat | cpp17 | Wrong answer 29/100 | 449ms | 37924 KiB |
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
ll n, s, o, a, MOD = 1e9 + 7, ans = 1;
vector <vector <int>> dp(2001, vector <int>(2001, 0));
vector <vector <bool>> b(2001, vector <bool>(2001, false));
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> s >> o;
dp[0][0] = 1;
for (int i = 1; i <= n; i++) {
dp[i][0] = (dp[i - 1][0] * i) % MOD;
for (int j = 1; j <= i; j++) {
dp[i][j] = (MOD + dp[i][j - 1] - dp[i - 1][j - 1]) % MOD;
}
}
fill(b[0].begin(), b[0].end(), true);
for (int i = 1; i <= s; i++) {
for (int j = 0; j < o; j++) {
cin >> a;
b[i][a] = true;
}
a = 0;
for (int j = 1; j <= n; j++) if (!b[i][j] && !b[i - 1][j]) a++;
ans *= dp[n - o][a];
ans %= MOD;
}
for (int i = 0; i < n - s; i++) {
ans *= dp[n][n];
ans %= MOD;
}
cout << ans;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 16ms | 34540 KiB | ||||
2 | Accepted | 13ms | 34792 KiB | ||||
3 | Wrong answer | 202ms | 34940 KiB | ||||
subtask2 | 5/5 | ||||||
4 | Accepted | 405ms | 35152 KiB | ||||
5 | Accepted | 425ms | 35368 KiB | ||||
6 | Accepted | 449ms | 35448 KiB | ||||
7 | Accepted | 437ms | 35712 KiB | ||||
subtask3 | 9/9 | ||||||
8 | Accepted | 13ms | 35800 KiB | ||||
9 | Accepted | 16ms | 35780 KiB | ||||
10 | Accepted | 428ms | 35780 KiB | ||||
11 | Accepted | 441ms | 36036 KiB | ||||
subtask4 | 15/15 | ||||||
12 | Accepted | 16ms | 35992 KiB | ||||
13 | Accepted | 16ms | 35992 KiB | ||||
14 | Accepted | 13ms | 36252 KiB | ||||
15 | Accepted | 16ms | 36464 KiB | ||||
16 | Accepted | 16ms | 36460 KiB | ||||
17 | Accepted | 13ms | 36680 KiB | ||||
18 | Accepted | 13ms | 36636 KiB | ||||
19 | Accepted | 13ms | 36624 KiB | ||||
subtask5 | 0/16 | ||||||
20 | Accepted | 16ms | 36628 KiB | ||||
21 | Accepted | 14ms | 36884 KiB | ||||
22 | Accepted | 441ms | 37152 KiB | ||||
23 | Wrong answer | 56ms | 37052 KiB | ||||
24 | Wrong answer | 182ms | 37316 KiB | ||||
subtask6 | 0/25 | ||||||
25 | Wrong answer | 19ms | 37304 KiB | ||||
26 | Accepted | 16ms | 37440 KiB | ||||
27 | Accepted | 19ms | 37368 KiB | ||||
28 | Wrong answer | 13ms | 37368 KiB | ||||
29 | Wrong answer | 14ms | 37368 KiB | ||||
30 | Wrong answer | 18ms | 37376 KiB | ||||
31 | Wrong answer | 18ms | 37372 KiB | ||||
32 | Wrong answer | 18ms | 37524 KiB | ||||
subtask7 | 0/30 | ||||||
33 | Wrong answer | 89ms | 37572 KiB | ||||
34 | Accepted | 81ms | 37440 KiB | ||||
35 | Accepted | 441ms | 37568 KiB | ||||
36 | Wrong answer | 64ms | 37708 KiB | ||||
37 | Wrong answer | 186ms | 37592 KiB | ||||
38 | Wrong answer | 321ms | 37544 KiB | ||||
39 | Wrong answer | 264ms | 37676 KiB | ||||
40 | Wrong answer | 85ms | 37552 KiB | ||||
41 | Wrong answer | 221ms | 37676 KiB | ||||
42 | Wrong answer | 340ms | 37924 KiB |