답안 #736145

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
736145 2023-05-05T09:05:21 Z marvinthang Zapina (COCI20_zapina) C++17
110 / 110
130 ms 1744 KB
/******************************
*    author : @marvinthang    *
*    date : 14 / 11 / 2021    *
******************************/
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define  superspeed  ios_base::sync_with_stdio(false);\
                     cin.tie(NULL);\
                     //cout.tie(NULL);
#define  file(name)  freopen(name".inp", "r", stdin);\
                     freopen(name".out", "w", stdout);
 
const       int MOD = 1e9 + 7; // 998244353;
const     double PI = 3.1415926535897932384626433832795; // acos((db)-1); atan(-1.0);
const      int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
const  long long oo = 1e18;
const       int MAX = 355;
 
void add(int &a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
}
 
int N, F[MAX][MAX][2], comb[MAX][MAX];
 
void prepare() {
    comb[0][0] = 1;
    for (int i = 1; i <= N; ++i) {
        comb[0][i] = 1;
        for (int j = 1; j <= i; ++j) {
            comb[j][i] = comb[j][i - 1];
            add(comb[j][i], comb[j - 1][i - 1]);
        }
    }
}
 
int main() {
    superspeed;
    cin >> N;
    prepare();
    F[0][0][0] = 1;
    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j <= N; ++j) {
            if (j >= i) add(F[i][j][1], 1LL * comb[i][j] * F[i - 1][j - i][0] % MOD);
            for (int k = 0; k <= j; ++k) {
                if (k != i) add(F[i][j][0], 1LL * comb[k][j] * F[i - 1][j - k][0] % MOD);
                add(F[i][j][1], 1LL * comb[k][j] * F[i - 1][j - k][1] % MOD);
            }
        }
    }
    cout << F[N][N][1] << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 59 ms 1448 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 13 ms 932 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 76 ms 1484 KB Output is correct
22 Correct 9 ms 844 KB Output is correct
23 Correct 1 ms 588 KB Output is correct
24 Correct 17 ms 1000 KB Output is correct
25 Correct 13 ms 980 KB Output is correct
26 Correct 23 ms 1100 KB Output is correct
27 Correct 116 ms 1716 KB Output is correct
28 Correct 119 ms 1612 KB Output is correct
29 Correct 111 ms 1612 KB Output is correct
30 Correct 116 ms 1668 KB Output is correct
31 Correct 120 ms 1632 KB Output is correct
32 Correct 112 ms 1724 KB Output is correct
33 Correct 116 ms 1740 KB Output is correct
34 Correct 115 ms 1644 KB Output is correct
35 Correct 117 ms 1740 KB Output is correct
36 Correct 118 ms 1744 KB Output is correct
37 Correct 130 ms 1700 KB Output is correct