Submission #1225399

#TimeUsernameProblemLanguageResultExecution timeMemory
1225399MarwenElarbiKangaroo (CEOI16_kangaroo)C++17
0 / 100
1 ms832 KiB
#include <bits/stdc++.h> using namespace std; const int nax=2e3+5; const int MOD=1e9+7; long long dp[nax][nax]; int main() { #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif int n,l,r; cin>>n>>l>>r; if(l>r) swap(l,r); dp[0][0]=1; for (int i = 1; i <= n; ++i) { for (int j = 0; j <= n-i+1; ++j) { if(j>0) dp[i][j]+=dp[i-1][j-1]; if(i<l){ dp[i][j]+=dp[i-1][j+1]*(j+1)*(j); }else if(i==l){ dp[i][j]+=dp[i-1][j+1]*(j+1); }else if(i<r){ dp[i][j]+=dp[i-1][j+1]*(j+1)*(j+1); }else if(i==r){ dp[i][j]+=dp[i-1][j]*(j+1); }else{ dp[i][j]+=dp[i-1][j+1]*(j+2)*(j+1); } //if(dp[i][j] > 0)cout << i << " "<<j<<" "<<dp[i][j]<<" "<<dp[i-1][j+1]<<endl; dp[i][j]%=MOD; } } cout <<dp[n-1][0]<<endl; }

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:8:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         freopen("input.txt","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:9:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |         freopen("output.txt","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...