# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
45875 | 3zp | Tents (JOI18_tents) | C++14 | 207 ms | 71268 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
long long dp[3009][3009];
long long mod = 1e9+7;
main(){
long long H,W;
cin >> H>> W;
for (long long i = 1; i<= H; i++){
dp[i][1]= i*(i-1)/2+4*i+1;
dp[i][0]= 1;
}
for (long long j=1; j<=W; j++){
dp[1][j] =j*(j-1)/2+4*j+1;
dp[0][j] = 1;
}
for(long long i =2; i<= H; i++){
for (long long j = 2; j<= W; j++){
dp[i][j]= (dp[i-1][j]+(4*j*dp[i-1][j-1])+j*(i-1)*dp[i-2][j-1]+j*(j-1)/2*dp[i-1][j-2])%mod;
}
}
cout<<(dp[H][W] + mod -1 )%mod<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |