(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #653106

#TimeUsernameProblemLanguageResultExecution timeMemory
653106damwuanKangaroo (CEOI16_kangaroo)C++14
0 / 100
1 ms340 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define bit(n,i) ((n>>i)&1) typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll maxn=2000+69; const ll mod=1e9+7; const ll inf=1e18; ll n,dp[maxn][maxn],cs,cf; void add(ll& x , ll y) { x += y; if(x >= mod)x -= mod; } void sol() { cin >> n>> cs>> cf; dp[0][0]=1; dp[1][0]=1; for (int i=1;i<=n;i++) { for (int j=0;j<=n;j++) { if (i!=cs && i!=cf) { if (j>0) add(dp[i][j],dp[i-1][j-1]); add(dp[i][j],dp[i-1][j+1]*(j+1)%mod*(j+(i>cs)+(i>cf))%mod); } else { add(dp[i][j],dp[i-1][j]); add(dp[i][j],dp[i-1][j+1]*j%mod); } // cout <<i<<' '<<j<<' '<< dp[i][j]<<'\n'; } //dp[1][0]=1; } cout <<dp[n][0]; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int t=1;//cin >> t; while (t--) { sol(); } } /* 6 7 0 1 0 2 1 2 1 3 3 6 1 2 2 4 2 5 5 6 1 6 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...