Submission #1242436

#TimeUsernameProblemLanguageResultExecution timeMemory
1242436ghammazhassanKangaroo (CEOI16_kangaroo)C++20
6 / 100
0 ms324 KiB
// #include <bits/stdc++.h> #include <iostream> #include <cmath> #include <algorithm> #include <map> #include <unordered_map> #include <vector> #include <iomanip> #include <string> #include <queue> #include <set> #include <deque> using namespace std; #define int long long #define endl "\n" #define fi first #define se second const int M=998244353; // const int inf = 3e9; const int LOG=19; const int N=2e3+5; int n , m , c , w , k , t=1 , q=1 , x , y , z , l , r; int dp[N][N][3]; void solve() { cin >> n >> x >> y; if (x==1 or y==1){ dp[1][1][1]=1; } else{ dp[1][1][0]=1; } for (int i=1;i<n;i++){ for (int j=1;j<=i;j++){ if (x==i+1 or y==i+1){ for (int k=0;k<2;k++){ dp[i+1][j+1][k+1]+=dp[i][j][k]; dp[i+1][j][k+1]+=dp[i][j][k]; } } else{ for (int k=0;k<3;k++){ dp[i+1][j+1][k]+=dp[i][j][k]*(j+1-k); // dp[i+1][j][k]+=dp[i][j][k]*(2*j-k); dp[i+1][j-1][k]+=dp[i][j][k]*(j-1); } } } } cout << dp[n][1][2] << endl; } signed main() { ios::sync_with_stdio(0);//DO NOT USE IN INTERACTIVE cin.tie(0), cout.tie(0);//DO NOT USE IN INTERACTIVE cout << fixed<<setprecision(9); srand(time(0)); // int t=1; // cin >> t; for (int _=1;_<=t;_++){ solve(); q++; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...