Submission #528796

# Submission time Handle Problem Language Result Execution time Memory
528796 2022-02-21T13:25:20 Z LucaDantas Asceticism (JOI18_asceticism) C++17
49 / 100
44 ms 24912 KB
#include <bits/stdc++.h>
using namespace std;

constexpr int maxn = 3e3 + 10, mod = 1000000007;

int dp[maxn][maxn];

int main() {
	int n, k; scanf("%d %d", &n, &k);
	dp[1][0] = 1; --k; // já gasto um dia naturalmente que não conta
	for(int i = 1; i <= n; i++) {
		for(int down = 0; down <= k; down++) {
			// printf("(%d %d -> %d) ", i, down, dp[i][down]);
			dp[i+1][down+1] += 1ll * (i - down) * dp[i][down] % mod;
			if(dp[i+1][down+1] >= mod) dp[i+1][down+1] -= mod;

			dp[i+1][down] += 1ll * (down + 1) * dp[i][down] % mod;
			if(dp[i+1][down] >= mod) dp[i+1][down] -= mod;
		}
		// puts("");
	}
	printf("%d\n", dp[n][k]);
}

Compilation message

asceticism.cpp: In function 'int main()':
asceticism.cpp:9:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  int n, k; scanf("%d %d", &n, &k);
      |            ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 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 0 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 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 0 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 1 ms 716 KB Output is correct
12 Correct 1 ms 1484 KB Output is correct
13 Correct 1 ms 1488 KB Output is correct
14 Correct 1 ms 1616 KB Output is correct
15 Correct 2 ms 1744 KB Output is correct
16 Correct 2 ms 1744 KB Output is correct
17 Correct 1 ms 1104 KB Output is correct
18 Correct 1 ms 1360 KB Output is correct
19 Correct 1 ms 848 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 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 0 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 1 ms 716 KB Output is correct
12 Correct 1 ms 1484 KB Output is correct
13 Correct 1 ms 1488 KB Output is correct
14 Correct 1 ms 1616 KB Output is correct
15 Correct 2 ms 1744 KB Output is correct
16 Correct 2 ms 1744 KB Output is correct
17 Correct 1 ms 1104 KB Output is correct
18 Correct 1 ms 1360 KB Output is correct
19 Correct 1 ms 848 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 3 ms 4304 KB Output is correct
22 Correct 3 ms 4304 KB Output is correct
23 Correct 6 ms 6096 KB Output is correct
24 Correct 6 ms 6224 KB Output is correct
25 Correct 10 ms 8016 KB Output is correct
26 Correct 10 ms 8232 KB Output is correct
27 Correct 10 ms 8212 KB Output is correct
28 Correct 5 ms 3888 KB Output is correct
29 Correct 1 ms 1104 KB Output is correct
30 Correct 11 ms 8032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 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 0 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 1 ms 716 KB Output is correct
12 Correct 1 ms 1484 KB Output is correct
13 Correct 1 ms 1488 KB Output is correct
14 Correct 1 ms 1616 KB Output is correct
15 Correct 2 ms 1744 KB Output is correct
16 Correct 2 ms 1744 KB Output is correct
17 Correct 1 ms 1104 KB Output is correct
18 Correct 1 ms 1360 KB Output is correct
19 Correct 1 ms 848 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 3 ms 4304 KB Output is correct
22 Correct 3 ms 4304 KB Output is correct
23 Correct 6 ms 6096 KB Output is correct
24 Correct 6 ms 6224 KB Output is correct
25 Correct 10 ms 8016 KB Output is correct
26 Correct 10 ms 8232 KB Output is correct
27 Correct 10 ms 8212 KB Output is correct
28 Correct 5 ms 3888 KB Output is correct
29 Correct 1 ms 1104 KB Output is correct
30 Correct 11 ms 8032 KB Output is correct
31 Runtime error 44 ms 24912 KB Execution killed with signal 11
32 Halted 0 ms 0 KB -