Submission #559047

# Submission time Handle Problem Language Result Execution time Memory
559047 2022-05-09T10:04:17 Z groshi Tents (JOI18_tents) C++17
100 / 100
233 ms 83020 KB
#include<iostream>

using namespace std;
int mod=1000000007;
long long dp[4000][4000];
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int h,w;
    cin>>h>>w;
    dp[1][1]=1;
    for(int i=2;i<=h+1;i++)
    {
        for(int j=2;j<=w+1;j++)
        {
            if(i==2)
                dp[i][j]=1;
            else dp[i][j]=dp[i-1][j];
            if(i==2 || j==2)
                dp[i][j]+=(j-1)*4;
            else dp[i][j]+=(j-1)*4*dp[i-1][j-1];
            dp[i][j]%=mod;
            if(i==3 || j==2)
                dp[i][j]+=(j-1)*(i-2);
            else dp[i][j]+=(j-1)*(i-2)*dp[i-2][j-1];
            dp[i][j]%=mod;
            if(i==2 || j==3)
                dp[i][j]+=(j-1)*(j-2)/2;
            else dp[i][j]+=((j-1)*(j-2)/2)*dp[i-1][j-2];
            dp[i][j]%=mod;
        }
    }
    cout<<dp[h+1][w+1]-1;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 456 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
7 Correct 1 ms 836 KB Output is correct
8 Correct 1 ms 1364 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 2 ms 1748 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 3 ms 2260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 456 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
7 Correct 1 ms 836 KB Output is correct
8 Correct 1 ms 1364 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 2 ms 1748 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 3 ms 2260 KB Output is correct
13 Correct 0 ms 324 KB Output is correct
14 Correct 4 ms 9684 KB Output is correct
15 Correct 146 ms 55044 KB Output is correct
16 Correct 9 ms 4052 KB Output is correct
17 Correct 33 ms 12976 KB Output is correct
18 Correct 40 ms 17128 KB Output is correct
19 Correct 177 ms 63048 KB Output is correct
20 Correct 132 ms 51148 KB Output is correct
21 Correct 89 ms 33924 KB Output is correct
22 Correct 97 ms 35556 KB Output is correct
23 Correct 52 ms 27380 KB Output is correct
24 Correct 227 ms 83020 KB Output is correct
25 Correct 166 ms 63244 KB Output is correct
26 Correct 206 ms 71640 KB Output is correct
27 Correct 233 ms 79988 KB Output is correct