# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
209794 | 2020-03-15T14:28:59 Z | FutymyClone | Zapina (COCI20_zapina) | C++14 | 164 ms | 1808 KB |
#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
# | 결과 | 실행 시간 | 메모리 | 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 | 4 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 | 4 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 | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 376 KB | Output is correct |
12 | Correct | 5 ms | 376 KB | Output is correct |
13 | Correct | 5 ms | 376 KB | Output is correct |
14 | Correct | 5 ms | 376 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | 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 | 4 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 | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 376 KB | Output is correct |
12 | Correct | 5 ms | 376 KB | Output is correct |
13 | Correct | 5 ms | 376 KB | Output is correct |
14 | Correct | 5 ms | 376 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 5 ms | 376 KB | Output is correct |
17 | Correct | 75 ms | 1484 KB | Output is correct |
18 | Correct | 5 ms | 504 KB | Output is correct |
19 | Correct | 20 ms | 1016 KB | Output is correct |
20 | Correct | 5 ms | 376 KB | Output is correct |
21 | Correct | 100 ms | 1528 KB | Output is correct |
22 | Correct | 16 ms | 888 KB | Output is correct |
23 | Correct | 6 ms | 632 KB | Output is correct |
24 | Correct | 24 ms | 1016 KB | Output is correct |
25 | Correct | 18 ms | 1016 KB | Output is correct |
26 | Correct | 32 ms | 1144 KB | Output is correct |
27 | Correct | 143 ms | 1784 KB | Output is correct |
28 | Correct | 139 ms | 1784 KB | Output is correct |
29 | Correct | 147 ms | 1784 KB | Output is correct |
30 | Correct | 139 ms | 1784 KB | Output is correct |
31 | Correct | 140 ms | 1784 KB | Output is correct |
32 | Correct | 140 ms | 1784 KB | Output is correct |
33 | Correct | 151 ms | 1800 KB | Output is correct |
34 | Correct | 143 ms | 1808 KB | Output is correct |
35 | Correct | 164 ms | 1780 KB | Output is correct |
36 | Correct | 146 ms | 1784 KB | Output is correct |
37 | Correct | 147 ms | 1784 KB | Output is correct |