Submission #1193905

#TimeUsernameProblemLanguageResultExecution timeMemory
1193905Muhammad_AneeqKangaroo (CEOI16_kangaroo)C++20
100 / 100
41 ms55112 KiB
/* بسم الله الرحمن الرحيم Author: (:Muhammad Aneeq:) */ #include <iostream> #warning check the output using namespace std; int const N=2e3+10,mod=1e9+7; long long dp[N][N][3]={}; inline void solve() { int n; int st,en; cin>>n; cin>>st>>en; dp[1][1][(st==1)+(en==1)]=1; for (int i=1;i<n;i++) { for (long long j=1;j<=i;j++) { if (i+1==st||i+1==en) { for (int k=1;k<=2;k++) { dp[i+1][j+1][k]+=(dp[i][j][k-1]); dp[i+1][j][k]+=(dp[i][j][k-1]); dp[i+1][j+1][k]%=mod; dp[i+1][j][k]%=mod; } } 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-1][k]+=(dp[i][j][k]*(j-1)); dp[i+1][j+1][k]%=mod; dp[i+1][j-1][k]%=mod; } } } } cout<<dp[n][1][2]<<endl; } int main() { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int t=1; for (int i=1;i<=t;i++) { solve(); } }

Compilation message (stderr)

kangaroo.cpp:8:2: warning: #warning check the output [-Wcpp]
    8 | #warning check the output
      |  ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...