Submission #1030825

#TimeUsernameProblemLanguageResultExecution timeMemory
1030825MarwenElarbiKangaroo (CEOI16_kangaroo)C++17
51 / 100
690 ms273968 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define fi first #define se second #define ll long long #define pb push_back #define ii pair<int,int> template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int nax=5e4+5; const int MOD=1e9+7; #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); long long dp[205][205][205][2]; int n,s,t; long long dfs(int x,int y,int z,int t){ if(x==1&&y==0&&z==0) return 1; if(x==0) return 0; if(dp[x][y][z][t]!=-1) return dp[x][y][z][t]; dp[x][y][z][t]=0; for (int i = 0; i < x; ++i) { if(i==y||(i==z&&x>2)) continue; if((i>y) != t) continue; dp[x][y][z][t]+= dfs(x-1,((i>y) ? i-1 : i),((y<z) ? z-1 : z), !t); dp[x][y][z][t]%=MOD; } //cout <<x<<" "<<y<<" "<<z<<" "<<t<<" "<<dp[x][y][z][t]<<endl; return dp[x][y][z][t]; } int main() { optimise; cin>>n>>s>>t; s--;t--; if(s>t) swap(s,t); memset(dp,-1,sizeof dp); cout << (dfs(n,s,t,0)+dfs(n,s,t,1))%MOD <<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...