제출 #972765

#제출 시각아이디문제언어결과실행 시간메모리
972765Beerus13캥거루 (CEOI16_kangaroo)C++14
100 / 100
12 ms14192 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long const int N = 2e3 + 5; const int mod = 1e9 + 7; void add(int &a, int b) { a += b; if(a >= mod) a -= mod; if(a < 0) a += mod; } int n, sta, fin; int dp[N][N]; void solve() { cin >> n >> sta >> fin; dp[0][0] = 1; for(int i = 1; i <= n; ++i) { for(int j = 1; j <= i; ++j) { if(i == sta || i == fin) { add(dp[i][j], (dp[i - 1][j - 1] + dp[i - 1][j]) % mod); } else { int res = j - (i > sta) - (i > fin); add(dp[i][j], (1ll * dp[i - 1][j - 1] * res + 1ll * j * dp[i - 1][j + 1]) % mod); } } } cout << dp[n][1] << '\n'; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int test = 1; // cin >> test; while(test--) solve(); return 0; } // https://oj.uz/problem/view/CEOI16_kangaroo
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...