# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
456243 |
2021-08-06T09:33:18 Z |
grt |
Zapina (COCI20_zapina) |
C++17 |
|
176 ms |
1780 KB |
#include <bits/stdc++.h>
#define ST first
#define ND second
#define PB push_back
using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
const int nax = 350 + 10, mod = 1e9 + 7;
int n;
int dp[nax][nax][2];
int bi[nax][nax];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
dp[0][0][0] = 1;
bi[0][0] = 1;
for(int i = 0; i <= n; ++i) {
for(int j = 0; j <= n; ++j) {
if(i == 0) {
bi[i][j] = (i == j);
} else if(j == 0) {
bi[i][j] = 1;
} else {
bi[i][j] = (bi[i - 1][j - 1] + bi[i - 1][j]) % mod;
}
//cout << i << " " << j << ": " << bi[i][j] << "\n";
}
}
for(int i = 1; i <= n; ++i) {
for(int g = 0; g <= n; ++g) {
for(int j = 0; j <= g; ++j) {
if(i != j) dp[i][g][0] = (dp[i][g][0] + (ll)bi[g][j] * dp[i - 1][g - j][0]) % mod;
dp[i][g][1] = (dp[i][g][1] + (ll)bi[g][j] * dp[i - 1][g - j][1]) % mod;
}
if(g >= i) {
dp[i][g][1] = (dp[i][g][1] + (ll)bi[g][i] * dp[i - 1][g - i][0]) % mod;
}
}
}
cout << dp[n][n][1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
316 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 |
1 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
316 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 |
1 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 |
86 ms |
1456 KB |
Output is correct |
18 |
Correct |
1 ms |
460 KB |
Output is correct |
19 |
Correct |
18 ms |
956 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
113 ms |
1700 KB |
Output is correct |
22 |
Correct |
15 ms |
964 KB |
Output is correct |
23 |
Correct |
2 ms |
588 KB |
Output is correct |
24 |
Correct |
23 ms |
1052 KB |
Output is correct |
25 |
Correct |
16 ms |
884 KB |
Output is correct |
26 |
Correct |
35 ms |
1096 KB |
Output is correct |
27 |
Correct |
156 ms |
1728 KB |
Output is correct |
28 |
Correct |
159 ms |
1696 KB |
Output is correct |
29 |
Correct |
166 ms |
1716 KB |
Output is correct |
30 |
Correct |
158 ms |
1696 KB |
Output is correct |
31 |
Correct |
160 ms |
1732 KB |
Output is correct |
32 |
Correct |
159 ms |
1700 KB |
Output is correct |
33 |
Correct |
162 ms |
1696 KB |
Output is correct |
34 |
Correct |
163 ms |
1660 KB |
Output is correct |
35 |
Correct |
162 ms |
1732 KB |
Output is correct |
36 |
Correct |
166 ms |
1772 KB |
Output is correct |
37 |
Correct |
176 ms |
1780 KB |
Output is correct |