Submission #201042

# Submission time Handle Problem Language Result Execution time Memory
201042 2020-02-09T07:20:14 Z gs14004 Zapina (COCI20_zapina) C++17
110 / 110
168 ms 1912 KB
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using pi = pair<int, int>;
using lint = long long;
const int mod = 1e9 + 7;
const int MAXN = 355;

int n;
int bino[MAXN][MAXN];
int dp[MAXN][MAXN][2];

int f(int x, int y, int z){
	if(x == 0) return y == 0 && z;
	if(~dp[x][y][z]) return dp[x][y][z];
	int ret = 0;
	for(int i=0; i<=y; i++){
		ret += 1ll * f(x - 1, y - i, z | (x == i)) * bino[y][i] % mod;
		if(ret >= mod) ret -= mod;
	}
	return dp[x][y][z] = ret;
}

int main(){
	cin >> n;
	for(int i=0; i<=n; i++){
		bino[i][0] = 1;
		for(int j=1; j<=i; j++){
			bino[i][j] = (bino[i-1][j] + bino[i-1][j-1]) % mod;
		}
	}
	memset(dp, -1, sizeof(dp));
	cout << f(n, n, 0) << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1272 KB Output is correct
2 Correct 5 ms 1272 KB Output is correct
3 Correct 5 ms 1272 KB Output is correct
4 Correct 5 ms 1272 KB Output is correct
5 Correct 5 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1272 KB Output is correct
2 Correct 5 ms 1272 KB Output is correct
3 Correct 5 ms 1272 KB Output is correct
4 Correct 5 ms 1272 KB Output is correct
5 Correct 5 ms 1272 KB Output is correct
6 Correct 5 ms 1272 KB Output is correct
7 Correct 5 ms 1276 KB Output is correct
8 Correct 5 ms 1400 KB Output is correct
9 Correct 11 ms 1400 KB Output is correct
10 Correct 5 ms 1272 KB Output is correct
11 Correct 5 ms 1272 KB Output is correct
12 Correct 7 ms 1272 KB Output is correct
13 Correct 5 ms 1272 KB Output is correct
14 Correct 5 ms 1272 KB Output is correct
15 Correct 5 ms 1272 KB Output is correct
16 Correct 5 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1272 KB Output is correct
2 Correct 5 ms 1272 KB Output is correct
3 Correct 5 ms 1272 KB Output is correct
4 Correct 5 ms 1272 KB Output is correct
5 Correct 5 ms 1272 KB Output is correct
6 Correct 5 ms 1272 KB Output is correct
7 Correct 5 ms 1276 KB Output is correct
8 Correct 5 ms 1400 KB Output is correct
9 Correct 11 ms 1400 KB Output is correct
10 Correct 5 ms 1272 KB Output is correct
11 Correct 5 ms 1272 KB Output is correct
12 Correct 7 ms 1272 KB Output is correct
13 Correct 5 ms 1272 KB Output is correct
14 Correct 5 ms 1272 KB Output is correct
15 Correct 5 ms 1272 KB Output is correct
16 Correct 5 ms 1272 KB Output is correct
17 Correct 90 ms 1656 KB Output is correct
18 Correct 6 ms 1404 KB Output is correct
19 Correct 22 ms 1528 KB Output is correct
20 Correct 5 ms 1276 KB Output is correct
21 Correct 105 ms 1784 KB Output is correct
22 Correct 17 ms 1528 KB Output is correct
23 Correct 6 ms 1400 KB Output is correct
24 Correct 29 ms 1528 KB Output is correct
25 Correct 20 ms 1528 KB Output is correct
26 Correct 34 ms 1528 KB Output is correct
27 Correct 144 ms 1784 KB Output is correct
28 Correct 157 ms 1784 KB Output is correct
29 Correct 154 ms 1784 KB Output is correct
30 Correct 150 ms 1788 KB Output is correct
31 Correct 153 ms 1784 KB Output is correct
32 Correct 160 ms 1784 KB Output is correct
33 Correct 162 ms 1888 KB Output is correct
34 Correct 168 ms 1784 KB Output is correct
35 Correct 160 ms 1784 KB Output is correct
36 Correct 162 ms 1912 KB Output is correct
37 Correct 154 ms 1784 KB Output is correct