| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 209794 | FutymyClone | Zapina (COCI20_zapina) | C++14 | 164 ms | 1808 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 355;
const int mod = 1e9 + 7;
int n, f[N][N], g[N][N], C[N][N];
void add (int &x, int y) {
    x += y;
    if (x >= mod) x -= mod;
}
int main(){
    scanf("%d", &n);
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            if (!i || !j || i == j) C[i][j] = 1;
            else C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
        }
    }
    f[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; j + k <= n; k++) {
                add(f[i + 1][j + k], 1LL * f[i][j] * C[n - j][k] % mod);
            }
        }
    }
    g[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; j + k <= n; k++) {
                if (k == i + 1) continue;
                add(g[i + 1][j + k], 1LL * g[i][j] * C[n - j][k] % mod);
            }
        }
    }
    int ans = f[n][n] - g[n][n];
    if (ans < 0) ans += mod;
    printf("%d", ans);
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
