Submission #680877

#TimeUsernameProblemLanguageResultExecution timeMemory
680877vjudge1Kangaroo (CEOI16_kangaroo)C++14
6 / 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(i == 1) return j == 1; int &res = f[i][j]; if(~res) return res; res = 0; if(i == s || i == t) res = dp(i - 1, j - 1) + dp(i - 1, j); else { res += dp(i - 1, j - 1) * (j - (i > s) - (i > t)) % mod, fix(res); res += dp(i - 1, j + 1) * (j) % mod, fix(res); } return res; } void solve() { cin >> n >> s >> t; if(s > t) swap(s, t); memset(f, -1, sizeof f); cout << dp(n, 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...