Submission #45221

# Submission time Handle Problem Language Result Execution time Memory
45221 2018-04-11T22:06:27 Z sorry_Benq Kangaroo (CEOI16_kangaroo) C++17
36 / 100
6 ms 1620 KB
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

int DPplus[41][41][41];
int DPminus[41][41][41];

int main(){
	int N, cs, cf; cin >> N >> cs >> cf;
	DPplus[2][1][2] = 1LL;
	DPminus[2][2][1] = 1LL;
	for (int i = 3; i <= 40; i++){
		for (int k = 1; k <= i; k++){
			for (int j = 1; j <= i; j++){
				if (k == j) continue;
				DPplus[i][j][k] = 0LL;
				DPminus[i][j][k] = 0LL;
				for (int l = 1; l <= j - 1; l++){
					int eps = (k > j);
					DPminus[i][j][k] += DPplus[i - 1][l][k - eps];
					DPminus[i][j][k] %= MOD;
				}
				for (int l = j + 1; l <= i; l++){
					int eps = (k > j);
					DPplus[i][j][k] += DPminus[i - 1][l - 1][k - eps];
					DPplus[i][j][k] %= MOD; 
				}
			}
		}
	}
	cout << (DPplus[N][cs][cf] + DPminus[N][cs][cf]) % MOD << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 760 KB Output is correct
2 Correct 5 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 760 KB Output is correct
2 Correct 5 ms 888 KB Output is correct
3 Correct 5 ms 928 KB Output is correct
4 Correct 5 ms 928 KB Output is correct
5 Correct 6 ms 928 KB Output is correct
6 Correct 6 ms 988 KB Output is correct
7 Correct 5 ms 1048 KB Output is correct
8 Correct 5 ms 1048 KB Output is correct
9 Correct 5 ms 1048 KB Output is correct
10 Correct 5 ms 1048 KB Output is correct
11 Correct 6 ms 1048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 760 KB Output is correct
2 Correct 5 ms 888 KB Output is correct
3 Correct 5 ms 928 KB Output is correct
4 Correct 5 ms 928 KB Output is correct
5 Correct 6 ms 928 KB Output is correct
6 Correct 6 ms 988 KB Output is correct
7 Correct 5 ms 1048 KB Output is correct
8 Correct 5 ms 1048 KB Output is correct
9 Correct 5 ms 1048 KB Output is correct
10 Correct 5 ms 1048 KB Output is correct
11 Correct 6 ms 1048 KB Output is correct
12 Runtime error 6 ms 1620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 760 KB Output is correct
2 Correct 5 ms 888 KB Output is correct
3 Correct 5 ms 928 KB Output is correct
4 Correct 5 ms 928 KB Output is correct
5 Correct 6 ms 928 KB Output is correct
6 Correct 6 ms 988 KB Output is correct
7 Correct 5 ms 1048 KB Output is correct
8 Correct 5 ms 1048 KB Output is correct
9 Correct 5 ms 1048 KB Output is correct
10 Correct 5 ms 1048 KB Output is correct
11 Correct 6 ms 1048 KB Output is correct
12 Runtime error 6 ms 1620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Halted 0 ms 0 KB -