50212023-04-09 22:02:33zsomborMisztikus táblázatcpp17Wrong answer 15/1001.08s37452 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted13ms34520 KiB
2Accepted16ms34792 KiB
3Wrong answer389ms35000 KiB
subtask20/5
4Accepted998ms35212 KiB
5Time limit exceeded1.05s35424 KiB
6Time limit exceeded1.072s18316 KiB
7Time limit exceeded1.077s18440 KiB
subtask30/9
8Accepted13ms35844 KiB
9Accepted17ms35800 KiB
10Time limit exceeded1.052s19012 KiB
11Time limit exceeded1.044s18988 KiB
subtask415/15
12Accepted13ms36108 KiB
13Accepted13ms36020 KiB
14Accepted13ms36308 KiB
15Accepted16ms36192 KiB
16Accepted14ms36172 KiB
17Accepted16ms36188 KiB
18Accepted14ms36276 KiB
19Accepted16ms36504 KiB
subtask50/16
20Accepted14ms36460 KiB
21Accepted16ms36736 KiB
22Time limit exceeded1.069s36692 KiB
23Wrong answer59ms36944 KiB
24Wrong answer405ms36948 KiB
subtask60/25
25Wrong answer21ms36948 KiB
26Accepted23ms36888 KiB
27Accepted26ms37144 KiB
28Wrong answer14ms37096 KiB
29Wrong answer18ms37092 KiB
30Wrong answer20ms37120 KiB
31Wrong answer17ms37092 KiB
32Wrong answer17ms37352 KiB
subtask70/30
33Wrong answer148ms37304 KiB
34Accepted127ms37304 KiB
35Time limit exceeded1.08s20268 KiB
36Wrong answer61ms37308 KiB
37Wrong answer347ms37304 KiB
38Wrong answer741ms37308 KiB
39Wrong answer560ms37452 KiB
40Wrong answer101ms37352 KiB
41Wrong answer435ms37356 KiB
42Wrong answer778ms37348 KiB