50202023-04-09 21:44:28zsomborMisztikus táblázatcpp17Wrong answer 0/1001.074s37556 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted13ms34532 KiB
2Wrong answer13ms34664 KiB
3Wrong answer368ms34860 KiB
subtask20/5
4Time limit exceeded1.001s35076 KiB
5Time limit exceeded1.054s35284 KiB
6Time limit exceeded1.069s18432 KiB
7Time limit exceeded1.062s18720 KiB
subtask30/9
8Wrong answer16ms35920 KiB
9Wrong answer16ms35800 KiB
10Time limit exceeded1.024s19036 KiB
11Time limit exceeded1.074s19220 KiB
subtask40/15
12Wrong answer16ms36224 KiB
13Accepted14ms36232 KiB
14Wrong answer16ms36496 KiB
15Accepted14ms36764 KiB
16Wrong answer13ms36708 KiB
17Accepted13ms36712 KiB
18Accepted16ms36648 KiB
19Accepted14ms36912 KiB
subtask50/16
20Wrong answer16ms36868 KiB
21Wrong answer16ms36860 KiB
22Time limit exceeded1.072s19752 KiB
23Wrong answer57ms36880 KiB
24Wrong answer404ms36880 KiB
subtask60/25
25Wrong answer25ms36852 KiB
26Accepted23ms36876 KiB
27Wrong answer24ms36876 KiB
28Wrong answer14ms36900 KiB
29Wrong answer18ms36924 KiB
30Wrong answer21ms36880 KiB
31Wrong answer20ms36908 KiB
32Wrong answer20ms36880 KiB
subtask70/30
33Wrong answer145ms37156 KiB
34Accepted128ms37132 KiB
35Time limit exceeded1.072s20116 KiB
36Wrong answer57ms37344 KiB
37Wrong answer317ms37300 KiB
38Wrong answer734ms37556 KiB
39Wrong answer532ms37468 KiB
40Wrong answer90ms37380 KiB
41Wrong answer407ms37360 KiB
42Wrong answer769ms37364 KiB