Submission #986032

#TimeUsernameProblemLanguageResultExecution timeMemory
986032vjudge1Kangaroo (CEOI16_kangaroo)C++14
100 / 100
21 ms31652 KiB
/*If we keep holding onto yesterday, what are we going to be tomorrow?*/ #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define int long long int #define dbg if(debugg) #define F first #define S second bool debugg = false; template <typename T> using order_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>; template <typename T> using minheap = priority_queue<T, vector<T>, greater<T>>; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int mod = 1000000007; int n, s, e; int dp[2002][2002]; void solve() { cin >> n >> s >> e; dp[1][1] = 1; for(int i = 2; i <= n; i ++){ for(int j = 1; j <= n; j ++){ if(i == s || i == e){ dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % mod; } else{ int x = (dp[i - 1][j + 1] * j) % mod; int y = (dp[i - 1][j - 1] * (j - (i > s) - (i > e))) % mod; dp[i][j] = (x + y) % mod; } } } cout << dp[n][1] << '\n'; } int32_t main() { ios::sync_with_stdio(0); cin.tie(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...