Submission #873915

# Submission time Handle Problem Language Result Execution time Memory
873915 2023-11-16T02:43:27 Z noiaint Zapina (COCI20_zapina) C++17
110 / 110
301 ms 6224 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
 
#define getbit(x, i) (((x) >> (i)) & 1)
#define bit(x) (1 << (x))
#define popcount __builtin_popcountll
 
mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());
long long rand(long long l, long long r) {
    return l + rd() % (r - l + 1);
}
 
const int N = 750 + 5;
const int mod = 1e9 + 7; // 998244353;
const int lg = 25; // lg + 1
const int inf = 1e9; // INT_MAX;
const long long llinf = 1e18; // LLONG_MAX;
 
template<class X, class Y>
bool minimize(X &a, Y b) {
    return a > b ? (a = b, true) : false;
}
 
template<class X, class Y>
bool maximize(X &a, Y b) {
    return a < b ? (a = b, true) : false;
}
 
template<class X, class Y>
bool add(X &a, Y b) {
    a += b;
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return true;
}
 
int MUL(int x, int y) {
    return 1LL * x * y % mod;
}
 
int n;
int c[N][N], f[N][N], g[N][N];
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    c[0][0] = 1;
 
    for (int i = 1; i <= 750; ++i)
        for (int j = 0; j <= i; ++j) {
            if (j == 0 || j == i) c[j][i] = 1;
            else {
                add(c[j][i], c[j - 1][i - 1]);
                add(c[j][i], c[j][i - 1]);
            }
        }
 
    cin >> n;
 
    f[0][0] = g[0][0] = 1;
 
    for (int i = 1; i <= n; ++i)
        for (int j = 0; j <= n; ++j)
            for (int k = 0; j - k >= 0; ++k) {
                add(f[i][j], MUL(f[i - 1][j - k], c[k][j]));
            }
 
    for (int i = 1; i <= n; ++i)
        for (int j = 0; j <= n; ++j)
            for (int k = 0; j - k >= 0; ++k) {
                if (k != i) add(g[i][j], MUL(g[i - 1][j - k], c[k][j]));
            }
 
    int res = f[n][n];
    add(res, -g[n][n]);
 
    cout << res;
 
    return 0;
}
 
/*
 
*/
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4700 KB Output is correct
2 Correct 2 ms 4820 KB Output is correct
3 Correct 2 ms 4696 KB Output is correct
4 Correct 3 ms 4700 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4700 KB Output is correct
2 Correct 2 ms 4820 KB Output is correct
3 Correct 2 ms 4696 KB Output is correct
4 Correct 3 ms 4700 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 3 ms 4956 KB Output is correct
7 Correct 3 ms 4952 KB Output is correct
8 Correct 2 ms 4908 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 2 ms 4952 KB Output is correct
11 Correct 3 ms 4952 KB Output is correct
12 Correct 3 ms 4916 KB Output is correct
13 Correct 2 ms 4824 KB Output is correct
14 Correct 3 ms 4912 KB Output is correct
15 Correct 3 ms 4952 KB Output is correct
16 Correct 3 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4700 KB Output is correct
2 Correct 2 ms 4820 KB Output is correct
3 Correct 2 ms 4696 KB Output is correct
4 Correct 3 ms 4700 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 3 ms 4956 KB Output is correct
7 Correct 3 ms 4952 KB Output is correct
8 Correct 2 ms 4908 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 2 ms 4952 KB Output is correct
11 Correct 3 ms 4952 KB Output is correct
12 Correct 3 ms 4916 KB Output is correct
13 Correct 2 ms 4824 KB Output is correct
14 Correct 3 ms 4912 KB Output is correct
15 Correct 3 ms 4952 KB Output is correct
16 Correct 3 ms 4956 KB Output is correct
17 Correct 143 ms 5868 KB Output is correct
18 Correct 4 ms 5212 KB Output is correct
19 Correct 33 ms 5424 KB Output is correct
20 Correct 3 ms 4952 KB Output is correct
21 Correct 190 ms 5968 KB Output is correct
22 Correct 24 ms 5468 KB Output is correct
23 Correct 4 ms 5160 KB Output is correct
24 Correct 50 ms 5468 KB Output is correct
25 Correct 30 ms 5464 KB Output is correct
26 Correct 57 ms 5492 KB Output is correct
27 Correct 274 ms 5992 KB Output is correct
28 Correct 282 ms 6012 KB Output is correct
29 Correct 276 ms 6088 KB Output is correct
30 Correct 278 ms 6224 KB Output is correct
31 Correct 281 ms 6092 KB Output is correct
32 Correct 292 ms 5976 KB Output is correct
33 Correct 283 ms 6100 KB Output is correct
34 Correct 290 ms 6048 KB Output is correct
35 Correct 296 ms 6220 KB Output is correct
36 Correct 301 ms 5880 KB Output is correct
37 Correct 300 ms 5972 KB Output is correct