Submission #385215

# Submission time Handle Problem Language Result Execution time Memory
385215 2021-04-03T17:19:21 Z pure_mem Kangaroo (CEOI16_kangaroo) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h> 
 
#define X first
#define Y second
#define MP make_pair
#define ll long long
 
using namespace std;
 
const int N = 2003;
const ll mod = 1e9 + 7, INF = 1e18; 

int n, cf, cs;
ll dp[N][N];

int main () {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> cs >> cf;
	if(cs > cf)
		swap(cf, cs);
	dp[n + 1][0] = 1;
	for(int i = n;i >= 1;i--){
		for(int j = 0;j <= n - i + 1;j++){	
			if(i > cf){
				dp[i][j] = ((j ? dp[i + 1][j - 1]: 0) + dp[i + 1][j + 1] * j * (j + 1)) % mod;
			}
			else if(i == cf){
				dp[i][j] = (dp[i + 1][j] + dp[i + 1][j + 1] * (j + 1)) % mod;
			}
			else if(cs < i){
				dp[i][j] = ((j ? dp[i + 1][j - 1]: 0) + dp[i + 1][j + 1] * (j + 1) * (j + 1)) % mod;	
			}
			else if(cs == i){
				dp[i][j] = (dp[i + 1][j] + dp[i + 1][j + 1] * (j + 1)) % mod;
			}
			else{
			    dp[i][j] = ((j ? dp[i + 1][j - 1]: 0) + dp[i + 1][j + 1] * (j + 2) * (j + 1)) % mod;	
			}
		}
	}
	cout << dp[1][0];
}               
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct