50222023-04-09 22:04:26zsomborMisztikus táblázatcpp17Wrong answer 29/100449ms37924 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted16ms34540 KiB
2Accepted13ms34792 KiB
3Wrong answer202ms34940 KiB
subtask25/5
4Accepted405ms35152 KiB
5Accepted425ms35368 KiB
6Accepted449ms35448 KiB
7Accepted437ms35712 KiB
subtask39/9
8Accepted13ms35800 KiB
9Accepted16ms35780 KiB
10Accepted428ms35780 KiB
11Accepted441ms36036 KiB
subtask415/15
12Accepted16ms35992 KiB
13Accepted16ms35992 KiB
14Accepted13ms36252 KiB
15Accepted16ms36464 KiB
16Accepted16ms36460 KiB
17Accepted13ms36680 KiB
18Accepted13ms36636 KiB
19Accepted13ms36624 KiB
subtask50/16
20Accepted16ms36628 KiB
21Accepted14ms36884 KiB
22Accepted441ms37152 KiB
23Wrong answer56ms37052 KiB
24Wrong answer182ms37316 KiB
subtask60/25
25Wrong answer19ms37304 KiB
26Accepted16ms37440 KiB
27Accepted19ms37368 KiB
28Wrong answer13ms37368 KiB
29Wrong answer14ms37368 KiB
30Wrong answer18ms37376 KiB
31Wrong answer18ms37372 KiB
32Wrong answer18ms37524 KiB
subtask70/30
33Wrong answer89ms37572 KiB
34Accepted81ms37440 KiB
35Accepted441ms37568 KiB
36Wrong answer64ms37708 KiB
37Wrong answer186ms37592 KiB
38Wrong answer321ms37544 KiB
39Wrong answer264ms37676 KiB
40Wrong answer85ms37552 KiB
41Wrong answer221ms37676 KiB
42Wrong answer340ms37924 KiB