답안 #201017

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
201017 2020-02-09T05:37:30 Z dolphingarlic Zapina (COCI20_zapina) C++14
110 / 110
136 ms 3324 KB
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

const ll MOD = 1e9 + 7;

inline ll madd(ll a, ll b) {
    a += b;
    if (a >= MOD) a -= MOD;
    return a;
}

inline ll mmult(ll a, ll b) {
    a = (a * b) % MOD;
    return a;
}

ll chs[351][351], dp[351][351], dp2[351][351];

int main() {
    iostream::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;

    FOR(i, 0, n + 1) chs[i][0] = 1;
    FOR(i, 1, n + 1) FOR(j, 1, i + 1) chs[i][j] = madd(chs[i - 1][j - 1], chs[i - 1][j]);

    dp[0][0] = dp2[0][0] = 1;
    FOR(i, 1, n + 1) FOR(j, 0, n + 1) {
        FOR(k, 0, j + 1) {
            if (k != i) dp[i][j] = madd(dp[i][j], mmult(dp[i - 1][j - k], chs[j][k]));
            dp2[i][j] = madd(dp2[i][j], mmult(dp2[i - 1][j - k], chs[j][k]));
        }
    }

    ll ans = 0;
    FOR(i, 1, n + 1) FOR(j, 0, n - i + 1) {
        ans = madd(ans, mmult(mmult(mmult(dp[i - 1][j], chs[n][j]), chs[n - j][i]), dp2[n - i][n - j - i]));
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 380 KB Output is correct
9 Correct 5 ms 504 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 5 ms 504 KB Output is correct
12 Correct 5 ms 504 KB Output is correct
13 Correct 5 ms 504 KB Output is correct
14 Correct 5 ms 504 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 380 KB Output is correct
9 Correct 5 ms 504 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 5 ms 504 KB Output is correct
12 Correct 5 ms 504 KB Output is correct
13 Correct 5 ms 504 KB Output is correct
14 Correct 5 ms 504 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 504 KB Output is correct
17 Correct 74 ms 2552 KB Output is correct
18 Correct 6 ms 760 KB Output is correct
19 Correct 19 ms 1656 KB Output is correct
20 Correct 5 ms 504 KB Output is correct
21 Correct 100 ms 2888 KB Output is correct
22 Correct 15 ms 1528 KB Output is correct
23 Correct 6 ms 892 KB Output is correct
24 Correct 23 ms 1788 KB Output is correct
25 Correct 18 ms 1656 KB Output is correct
26 Correct 32 ms 1916 KB Output is correct
27 Correct 130 ms 3192 KB Output is correct
28 Correct 126 ms 3292 KB Output is correct
29 Correct 127 ms 3192 KB Output is correct
30 Correct 130 ms 3184 KB Output is correct
31 Correct 133 ms 3292 KB Output is correct
32 Correct 132 ms 3192 KB Output is correct
33 Correct 131 ms 3192 KB Output is correct
34 Correct 135 ms 3196 KB Output is correct
35 Correct 136 ms 3324 KB Output is correct
36 Correct 136 ms 3192 KB Output is correct
37 Correct 134 ms 3192 KB Output is correct