Submission #797908

# Submission time Handle Problem Language Result Execution time Memory
797908 2023-07-30T06:35:21 Z vjudge1 Tents (JOI18_tents) C++17
48 / 100
2000 ms 65324 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;

void norm(ll &x) {
    if(x >= MOD) x -= MOD;
    if(x < 0) x += MOD;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int h, w;
    cin >> h >> w;
    vector<vector<ll>> dp(w + 10, vector<ll>(w + 10));
    dp[0][0] = 1;
    for(ll i = 1; i <= h; i++) {
        vector<vector<ll>> new_dp(w + 10, vector<ll>(w + 10));
        for(ll j = 0; j <= w; j++) {
            for(ll k = 0; k <= j; k++) {
                ll val = dp[j][k];
                if(!val) continue;
                new_dp[j][k] += val,
                norm(new_dp[j][k]);
                new_dp[j + 2][k] += (w - j) * (w - j - 1) / 2 * val % MOD,
                norm(new_dp[j + 2][k]);
                new_dp[j + 1][k] += (w - j) * 4 * val % MOD; 
                norm(new_dp[j + 1][k]);
                new_dp[j + 1][k + 1] += val * (w - j) % MOD;
                norm(new_dp[j + 1][k + 1]);
                if(!k) continue;
                new_dp[j][k - 1] += val * k % MOD;
                norm(new_dp[j][k - 1]);
            }
        }
        dp = new_dp;
    }
    ll ans = 0;
    for(int j = 1; j <= w; j++) ans += dp[j][0], norm(ans);
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 852 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 12 ms 1412 KB Output is correct
6 Correct 19 ms 468 KB Output is correct
7 Correct 16 ms 1180 KB Output is correct
8 Correct 12 ms 388 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 60 ms 668 KB Output is correct
11 Correct 3 ms 1784 KB Output is correct
12 Correct 220 ms 1844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 852 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 12 ms 1412 KB Output is correct
6 Correct 19 ms 468 KB Output is correct
7 Correct 16 ms 1180 KB Output is correct
8 Correct 12 ms 388 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 60 ms 668 KB Output is correct
11 Correct 3 ms 1784 KB Output is correct
12 Correct 220 ms 1844 KB Output is correct
13 Correct 27 ms 54124 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Execution timed out 2058 ms 65324 KB Time limit exceeded
16 Halted 0 ms 0 KB -