Submission #1109371

#TimeUsernameProblemLanguageResultExecution timeMemory
1109371ASN49KKangaroo (CEOI16_kangaroo)C++14
36 / 100
74 ms15824 KiB
#include <bits/stdc++.h> #include <sys/time.h> using namespace std; using i64=long long; #define UNUSED -1 #define all(x) x.begin(),x.end() #define pb push_back const int mod=1e9+7,inf=1e9+1; const i64 INF=1e18; int add(int x,int y) { return (x+y)%mod; } void add_self(int& x,int y) { x+=y; if(x>=mod) { x-=mod; } } int prod(int x,int y) { return (1LL*x*y)%mod; } mt19937 rng(69); const int N=100; int dp[N][N][N][2]; int signatura(int x) { if(x>=0) { return 1; } return 0; } int main() { int n,start,finish; cin>>n>>start>>finish; dp[0][0][0][0]=dp[0][0][0][1]=1; for(int step=1;step<n;step++) { for(int poz_start=0;poz_start<step;poz_start++) { for(int now=0;now<=step;now++) { int sol[2]={0,0}; for(int middle=0;middle<step;middle++) { add_self(sol[signatura(middle-now)] , dp[step-1][poz_start][middle][signatura(middle-now)^1]); } dp[step][poz_start+(now<=poz_start)][now][0]=sol[0]; dp[step][poz_start+(now<=poz_start)][now][1]=sol[1]; } } } cout<<add(dp[n-1][start-1][finish-1][0],dp[n-1][start-1][finish-1][1]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...