Submission #883434

# Submission time Handle Problem Language Result Execution time Memory
883434 2023-12-05T09:22:22 Z phoenix0423 Kangaroo (CEOI16_kangaroo) C++17
0 / 100
0 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
// #pragma GCC optimize("Ofast")
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 0, n + 1)
#define SZ(x) (int)(x).size()
#define pb push_back
#define pf push_front
#define eb emplace_back
#define f first
#define s second
#define lowbit(x) x&-x
#define ckmin(a, b) a = min(a, b)
#define ckmax(a, b) a = max(a, b)
#define int long long
const int INF = 1e18;
const int N = 1e9 + 7;
const int maxn = 2005;
ll dp[maxn][maxn];

signed main(void){
	fastio;
	int n, s, t;
	cin>>n>>s>>t;
	dp[0][0] = 1;
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= i; j++){
			if(s == i || t == i){
				cnt++;
				dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % N;
			}
			else dp[i][j] = (dp[i - 1][j + 1] * j + dp[i - 1][j - 1] * (j - cnt)) % N;
		}
	}
	cout<<dp[n][1]<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -