# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
442913 | 2021-07-09T10:47:37 Z | Soumya1 | Zapina (COCI20_zapina) | C++14 | 141 ms | 1728 KB |
#include <bits/stdc++.h> using namespace std; int dp[351][351][2]; int c[351][351]; const int mod = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; c[0][0] = 1; for (int i = 1; i <= n; i++) { c[i][0] = c[i][i] = 1; for (int j = 1; j < i; j++) { c[i][j] = c[i - 1][j - 1] + c[i - 1][j]; if (c[i][j] >= mod) c[i][j] -= mod; } } dp[0][0][0] = 1; for (int i = 1; i <= n; i++) { for (int j = 0; j <= n; j++) { for (int k = 0; k <= j; k++) { if (i == k) { dp[i][j][1] += (1LL * c[j][k] * (dp[i - 1][j - k][0] + dp[i - 1][j - k][1])) % mod; if (dp[i][j][1] >= mod) dp[i][j][1] -= mod; continue; } dp[i][j][1] += (1LL * c[j][k] * dp[i - 1][j - k][1]) % mod; dp[i][j][0] += (1LL * c[j][k] * dp[i - 1][j - k][0]) % mod; if (dp[i][j][1] >= mod) dp[i][j][1] -= mod; if (dp[i][j][0] >= mod) dp[i][j][0] -= mod; } } } int ans = 0; cout << dp[n][n][1] << "\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 66 ms | 1420 KB | Output is correct |
18 | Correct | 1 ms | 460 KB | Output is correct |
19 | Correct | 15 ms | 940 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 90 ms | 1504 KB | Output is correct |
22 | Correct | 10 ms | 864 KB | Output is correct |
23 | Correct | 1 ms | 576 KB | Output is correct |
24 | Correct | 19 ms | 980 KB | Output is correct |
25 | Correct | 13 ms | 972 KB | Output is correct |
26 | Correct | 26 ms | 1052 KB | Output is correct |
27 | Correct | 123 ms | 1640 KB | Output is correct |
28 | Correct | 128 ms | 1628 KB | Output is correct |
29 | Correct | 131 ms | 1604 KB | Output is correct |
30 | Correct | 128 ms | 1688 KB | Output is correct |
31 | Correct | 129 ms | 1724 KB | Output is correct |
32 | Correct | 130 ms | 1728 KB | Output is correct |
33 | Correct | 129 ms | 1652 KB | Output is correct |
34 | Correct | 134 ms | 1668 KB | Output is correct |
35 | Correct | 131 ms | 1640 KB | Output is correct |
36 | Correct | 134 ms | 1668 KB | Output is correct |
37 | Correct | 141 ms | 1696 KB | Output is correct |