Submission #1093612

#TimeUsernameProblemLanguageResultExecution timeMemory
1093612Mike_VuKangaroo (CEOI16_kangaroo)C++14
100 / 100
17 ms16200 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double dou; #define pii pair<int, int> #define fi first #define se second #define pb push_back #define MASK(x) (1LL<<(x)) #define BIT(x, j) (((x)>>(j))&1) template<typename T> bool maximize(T &x, const T &y) { if (x < y) {x = y; return 1;} return 0; } template<typename T> bool minimize(T &x, const T &y) { if (x > y) {x = y; return 1;} return 0; } namespace modulofunc{ const int mod = 1e9+7; void ad(int &x, int y) { ll temp = x+y; if (temp >= mod) temp -= mod; x = temp; } int add(int x, int y) { ll temp = x+y; if (temp >= mod) temp -= mod; return temp; } int sub(int x, int y) { ll temp = x-y; if (temp < 0) temp += mod; return temp; } int mul(int x, int y) { return 1LL*x*y%mod; } } using namespace modulofunc; const int maxn = 2005; int n, cs, cf; int dp[maxn][maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); // #define name "task" // if (fopen(name".inp", "r")) { // freopen(name".inp", "r", stdin); // freopen(name".out", "w", stdout); // } cin >> n >> cs >> cf; memset(dp, 0, sizeof(dp)); dp[0][0] = 1; for (int i = 0; i < n; i++) { for (int j = 0; j <= i; j++) { if (!dp[i][j]) continue; if (i+1 == cs || i+1 == cf) { ad(dp[i+1][j], dp[i][j]); //join > ad(dp[i+1][j+1], dp[i][j]); //new < } else { //join if (i > 1) ad(dp[i+1][j-1], mul(dp[i][j], j-1)); //new ad(dp[i+1][j+1], mul(dp[i][j], j-1+(i+1<cs)+(i+1<cf))); } } } cout << dp[n][1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...