Submission #933726

# Submission time Handle Problem Language Result Execution time Memory
933726 2024-02-26T07:55:04 Z parlimoos Tents (JOI18_tents) C++14
100 / 100
40 ms 70708 KB
//Be Name KHODA
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
#define pb push_back
#define pp pop_back
#define lb lower_bound
#define ub upper_bound
#define cl clear
#define bg begin
#define arr(x) array<int , x>
#define endl '\n'

const int MOD = int(1e9) + 7;

int n , m;
ll dp[3001][3001];

int main(){
    cin >> n >> m;
    dp[n][m] = 1;
    for(int i = n ; i > 0 ; i--){
        for(int j = m ; j >= 0 ; j--){
            dp[i][j] %= MOD;
            dp[i - 1][j] += dp[i][j];
            if(m > 0){
                dp[i - 1][j - 1] += j * 4 * dp[i][j];
                if(i > 1) dp[i - 2][j - 1] += j * (i - 1) * dp[i][j];
            }
            if(m > 1) dp[i - 1][j - 2] += j * (j - 1) / 2 * dp[i][j];
        }
    }
    ll o = 0;
    for(int j = m - 1 ; j >= 0 ; j--) o += dp[0][j];
    cout << o % MOD;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 6588 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 8540 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 6588 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 8540 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 8540 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 14 ms 55644 KB Output is correct
15 Correct 28 ms 66128 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 7 ms 16824 KB Output is correct
18 Correct 9 ms 29276 KB Output is correct
19 Correct 31 ms 70152 KB Output is correct
20 Correct 25 ms 57936 KB Output is correct
21 Correct 16 ms 39512 KB Output is correct
22 Correct 18 ms 51800 KB Output is correct
23 Correct 14 ms 70236 KB Output is correct
24 Correct 40 ms 70708 KB Output is correct
25 Correct 31 ms 62044 KB Output is correct
26 Correct 35 ms 68180 KB Output is correct
27 Correct 39 ms 70228 KB Output is correct