제출 #1000465

#제출 시각아이디문제언어결과실행 시간메모리
1000465PagodePaiva캥거루 (CEOI16_kangaroo)C++17
100 / 100
13 ms31836 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define tii tuple<int,int,int> #define pii pair<int,int> #define ff first #define ss second #define all(x) x.begin(),x.end() #define allr(x) x.rbegin(),x.rend() #define pb push_back #define mp make_pair const int maxn = 2e3+5, MOD=1e9+7; int dp[maxn][maxn]; void solve(){ int n,cs,cf; cin >> n >> cs >> cf; dp[0][0] = 1; for(int k=1; k<=n; k++){ for(int c=1; c<=n; c++){ int p = (k>cs)+(k>cf); // uniao (n_c2 - (k>cs) - (k>cf) jeitos) e criar (1 jeito) dp[k][c] = (dp[k-1][c+1]*(c*(c+1) -p*c+(k==n && c==1)) + dp[k-1][c-1])%MOD; if(k==min(cs,cf)){ // extensao (c jeitos) e criar (1 jeito) dp[k][c] = (dp[k-1][c]*c + dp[k-1][c-1])%MOD; } if(k==max(cs,cf)){ // extensao (c-1 jeitos) e criar (1 jeito) dp[k][c] = (dp[k-1][c]*(c-(k<n)) + dp[k-1][c-1])%MOD; } // cout << dp[k][c] << " "; } // cout << endl; } cout << dp[n][1] << '\n'; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); int t=1; // cin >> t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...