5020 | 2023-04-09 21:44:28 | zsombor | Misztikus táblázat | cpp17 | Wrong answer 0/100 | 1.074s | 37556 KiB |
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
ll n, s, o, a, k, 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;
}
}
for (int i = 1; i <= s; i++) {
k = 0;
for (int j = 0; j < o; j++) {
cin >> a;
b[i][a] = true;
k += b[i - 1][a];
}
ans *= dp[n - o][k];
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 | 34532 KiB | ||||
2 | Wrong answer | 13ms | 34664 KiB | ||||
3 | Wrong answer | 368ms | 34860 KiB | ||||
subtask2 | 0/5 | ||||||
4 | Time limit exceeded | 1.001s | 35076 KiB | ||||
5 | Time limit exceeded | 1.054s | 35284 KiB | ||||
6 | Time limit exceeded | 1.069s | 18432 KiB | ||||
7 | Time limit exceeded | 1.062s | 18720 KiB | ||||
subtask3 | 0/9 | ||||||
8 | Wrong answer | 16ms | 35920 KiB | ||||
9 | Wrong answer | 16ms | 35800 KiB | ||||
10 | Time limit exceeded | 1.024s | 19036 KiB | ||||
11 | Time limit exceeded | 1.074s | 19220 KiB | ||||
subtask4 | 0/15 | ||||||
12 | Wrong answer | 16ms | 36224 KiB | ||||
13 | Accepted | 14ms | 36232 KiB | ||||
14 | Wrong answer | 16ms | 36496 KiB | ||||
15 | Accepted | 14ms | 36764 KiB | ||||
16 | Wrong answer | 13ms | 36708 KiB | ||||
17 | Accepted | 13ms | 36712 KiB | ||||
18 | Accepted | 16ms | 36648 KiB | ||||
19 | Accepted | 14ms | 36912 KiB | ||||
subtask5 | 0/16 | ||||||
20 | Wrong answer | 16ms | 36868 KiB | ||||
21 | Wrong answer | 16ms | 36860 KiB | ||||
22 | Time limit exceeded | 1.072s | 19752 KiB | ||||
23 | Wrong answer | 57ms | 36880 KiB | ||||
24 | Wrong answer | 404ms | 36880 KiB | ||||
subtask6 | 0/25 | ||||||
25 | Wrong answer | 25ms | 36852 KiB | ||||
26 | Accepted | 23ms | 36876 KiB | ||||
27 | Wrong answer | 24ms | 36876 KiB | ||||
28 | Wrong answer | 14ms | 36900 KiB | ||||
29 | Wrong answer | 18ms | 36924 KiB | ||||
30 | Wrong answer | 21ms | 36880 KiB | ||||
31 | Wrong answer | 20ms | 36908 KiB | ||||
32 | Wrong answer | 20ms | 36880 KiB | ||||
subtask7 | 0/30 | ||||||
33 | Wrong answer | 145ms | 37156 KiB | ||||
34 | Accepted | 128ms | 37132 KiB | ||||
35 | Time limit exceeded | 1.072s | 20116 KiB | ||||
36 | Wrong answer | 57ms | 37344 KiB | ||||
37 | Wrong answer | 317ms | 37300 KiB | ||||
38 | Wrong answer | 734ms | 37556 KiB | ||||
39 | Wrong answer | 532ms | 37468 KiB | ||||
40 | Wrong answer | 90ms | 37380 KiB | ||||
41 | Wrong answer | 407ms | 37360 KiB | ||||
42 | Wrong answer | 769ms | 37364 KiB |