답안 #961063

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
961063 2024-04-11T13:09:31 Z simona1230 Tents (JOI18_tents) C++17
100 / 100
71 ms 70844 KB
#include <bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long n,m;
long long dp[3001][3001];
void solve()
{
    cin>>n>>m;

    dp[0][0]=1;
    for(long long i=1;i<=n;i++)
        dp[i][0]=1;
    for(long long i=1;i<=m;i++)
        dp[0][i]=1;
    for(long long i=1;i<=n;i++)
    {
        for(long long j=1;j<=m;j++)
        {
            dp[i][j]=dp[i-1][j];
            dp[i][j]%=mod;
            if(i>=2)dp[i][j]+=dp[i-2][j-1]*j*(i-1);
            dp[i][j]%=mod;
            if(j>=2)dp[i][j]+=dp[i-1][j-2]*(j-1)*j/2;
            dp[i][j]%=mod;
            dp[i][j]+=dp[i-1][j-1]*j*4;
            dp[i][j]%=mod;
            //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
        }
    }
    cout<<dp[n][m]-1<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 2 ms 8540 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 2 ms 8540 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 8540 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 20 ms 55876 KB Output is correct
15 Correct 54 ms 66140 KB Output is correct
16 Correct 5 ms 6488 KB Output is correct
17 Correct 12 ms 16988 KB Output is correct
18 Correct 15 ms 29140 KB Output is correct
19 Correct 56 ms 70236 KB Output is correct
20 Correct 48 ms 58052 KB Output is correct
21 Correct 29 ms 39512 KB Output is correct
22 Correct 31 ms 51800 KB Output is correct
23 Correct 24 ms 70488 KB Output is correct
24 Correct 71 ms 70844 KB Output is correct
25 Correct 53 ms 62176 KB Output is correct
26 Correct 58 ms 68188 KB Output is correct
27 Correct 67 ms 70384 KB Output is correct