제출 #680885

#제출 시각아이디문제언어결과실행 시간메모리
680885vjudge1캥거루 (CEOI16_kangaroo)C++14
0 / 100
7 ms15956 KiB
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define pb push_back #define all(a) a.begin(), a.end() typedef long long ll; typedef pair<int, int> ii; const int N = 2000 + 5; const int mod = 1e9 + 7; int n, s, t; int f[N][N]; void fix(int &a) { if(a >= mod) a -= mod; if(a < 0) a += mod; } int dp(int i, int j) { if(j < 1) return 0; if(i == n) return j == 1; int &res = f[i][j]; if(~res) return res; res = 0; if(i == s || i == t) res += dp(i + 1, j) + dp(i + 1, j + 1), fix(res); else { res += 1LL * dp(i + 1, j - 1) * (j - 1) % mod, fix(res); res += 1LL * dp(i + 1, j + 1) * (j + 1 - (i > s) - (i > t)) % mod, fix(res); } return res; } void solve() { cin >> n >> s >> t; if(s > t) swap(s, t); memset(f, -1, sizeof f); cout << dp(1, 1); } signed main() { cin.tie(0)->sync_with_stdio(0); int t = 1; // cin >> t; while(t--) 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...