제출 #529212

#제출 시각아이디문제언어결과실행 시간메모리
529212Mondeus캥거루 (CEOI16_kangaroo)C++17
0 / 100
1 ms332 KiB
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <string> #include <cstring> #include <iomanip> #include <map> #include <queue> using namespace std; const int maxn = 2e3; int n,s,e; long long dp[maxn+5][maxn+5]; const int MOD = 1e9+7; void solve() { cin >> n >> s >> e; dp[1][1] = 1; for(int i = 1; i < n; i++) { for(int j = 1; j <= i; j++) { if(i + 1 == s || i + 1 == e) dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j]) % MOD, dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD; else { dp[i+1][j+1] = (dp[i+1][j+1] + (j - (i >= s) - (i >= e)) * dp[i][j]) % MOD; dp[i+1][j-1] = (dp[i+1][j-1] + (j - 1) * dp[i][j]) % MOD; } } } cout << dp[n][1]; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...