5021 | 2023-04-09 22:02:33 | zsombor | Misztikus táblázat | cpp17 | Wrong answer 15/100 | 1.08s | 37452 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()
{
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 | 13ms | 34520 KiB | ||||
2 | Accepted | 16ms | 34792 KiB | ||||
3 | Wrong answer | 389ms | 35000 KiB | ||||
subtask2 | 0/5 | ||||||
4 | Accepted | 998ms | 35212 KiB | ||||
5 | Time limit exceeded | 1.05s | 35424 KiB | ||||
6 | Time limit exceeded | 1.072s | 18316 KiB | ||||
7 | Time limit exceeded | 1.077s | 18440 KiB | ||||
subtask3 | 0/9 | ||||||
8 | Accepted | 13ms | 35844 KiB | ||||
9 | Accepted | 17ms | 35800 KiB | ||||
10 | Time limit exceeded | 1.052s | 19012 KiB | ||||
11 | Time limit exceeded | 1.044s | 18988 KiB | ||||
subtask4 | 15/15 | ||||||
12 | Accepted | 13ms | 36108 KiB | ||||
13 | Accepted | 13ms | 36020 KiB | ||||
14 | Accepted | 13ms | 36308 KiB | ||||
15 | Accepted | 16ms | 36192 KiB | ||||
16 | Accepted | 14ms | 36172 KiB | ||||
17 | Accepted | 16ms | 36188 KiB | ||||
18 | Accepted | 14ms | 36276 KiB | ||||
19 | Accepted | 16ms | 36504 KiB | ||||
subtask5 | 0/16 | ||||||
20 | Accepted | 14ms | 36460 KiB | ||||
21 | Accepted | 16ms | 36736 KiB | ||||
22 | Time limit exceeded | 1.069s | 36692 KiB | ||||
23 | Wrong answer | 59ms | 36944 KiB | ||||
24 | Wrong answer | 405ms | 36948 KiB | ||||
subtask6 | 0/25 | ||||||
25 | Wrong answer | 21ms | 36948 KiB | ||||
26 | Accepted | 23ms | 36888 KiB | ||||
27 | Accepted | 26ms | 37144 KiB | ||||
28 | Wrong answer | 14ms | 37096 KiB | ||||
29 | Wrong answer | 18ms | 37092 KiB | ||||
30 | Wrong answer | 20ms | 37120 KiB | ||||
31 | Wrong answer | 17ms | 37092 KiB | ||||
32 | Wrong answer | 17ms | 37352 KiB | ||||
subtask7 | 0/30 | ||||||
33 | Wrong answer | 148ms | 37304 KiB | ||||
34 | Accepted | 127ms | 37304 KiB | ||||
35 | Time limit exceeded | 1.08s | 20268 KiB | ||||
36 | Wrong answer | 61ms | 37308 KiB | ||||
37 | Wrong answer | 347ms | 37304 KiB | ||||
38 | Wrong answer | 741ms | 37308 KiB | ||||
39 | Wrong answer | 560ms | 37452 KiB | ||||
40 | Wrong answer | 101ms | 37352 KiB | ||||
41 | Wrong answer | 435ms | 37356 KiB | ||||
42 | Wrong answer | 778ms | 37348 KiB |