Submission #1193904

#TimeUsernameProblemLanguageResultExecution timeMemory
1193904Sir_Ahmed_ImranKangaroo (CEOI16_kangaroo)C++17
100 / 100
27 ms31048 KiB
// 01001100 01001111 01010100 01000001 \\ // \\ // ╦ ╔═╗╔╦╗╔═╗ \\ // ║ ║ ║ ║ ╠═╣ \\ // ╩═╝╚═╝ ╩ ╩ ╩ \\ // \\ // 01001100 01001111 01010100 01000001 \\ #include <bits/stdc++.h> using namespace std; #define N 2001 #define nl '\n' #define ff first #define ss second #define add insert #define ll long long #define ld long double #define terminator main #define pll pair<ll,ll> #define append push_back #define pii pair<int,int> #define all(x) (x).begin(),(x).end() #define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) const int M = 1e9 + 7; int add(int x, int y){ return (x + y) % M; } int mul(int x, int y){ return (1ll * x * y) % M; } int dp[N][N][3]; void solve(){ int n, s, e, t; cin >> n >> s >> e; t = (s == 1) + (e == 1); dp[1][1][t] = 1; for(int i = 2; i <= n; i++){ for(int j = 1; j < i; j++){ if(s == i || e == i){ dp[i][j][t + 1] = add(dp[i][j][t + 1], dp[i - 1][j][t]); dp[i][j + 1][t + 1] = add(dp[i][j + 1][t + 1], dp[i - 1][j][t]); } else{ dp[i][j - 1][t] = add(dp[i][j - 1][t], mul(dp[i - 1][j][t], j - 1)); dp[i][j + 1][t] = add(dp[i][j + 1][t], mul(dp[i - 1][j][t], j + 1 - t)); } } t += (s == i || e == i); } cout << dp[n][1][2]; } int terminator(){ L0TA; 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...