# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
861002 |
2023-10-15T05:46:22 Z |
Cookie |
Tents (JOI18_tents) |
C++14 |
|
134 ms |
70996 KB |
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define vt vector
#define pb push_back
#define pii pair<int, int>
#define sz(dq) (int)dq.size()
#define forr(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pll pair<ll, ll>
ifstream fin("store.inp");
ofstream fout("store.out");
const ll mxn = 5e5 + 5, inf = 1e9, mod = 1e9 + 7, sq = 800, mxv = 1e6 + 5, pr = 37, mod2 = 1e9 + 9, mod3 = 998244353;
//const int x[4] = {0, -1, 0, 1};
int n, m;
ll dp[3005][3005];
void add(ll &a, ll b){
a += b;
if(a >= mod)a %= mod;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
for(int i = 0; i <= m; i++)dp[0][i] = 1;
for(int i = 0; i <= n; i++)dp[i][0] = 1;
for(ll i = 1; i <= n; i++){
for(ll j = 1; j <= m; j++){
add(dp[i][j], dp[i - 1][j - 1] * j * 4);
if(j >= 2){
add(dp[i][j], dp[i - 1][j - 2] * j * (j - 1) / 2);
}if(i >= 2){
add(dp[i][j], dp[i - 2][j - 1] * j * (i - 1));
}add(dp[i][j], dp[i - 1][j]);
}
}
cout << (dp[n][m] - 1 + mod) % mod;
return(0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 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 |
4596 KB |
Output is correct |
10 |
Correct |
2 ms |
8540 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
2 ms |
8540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 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 |
4596 KB |
Output is correct |
10 |
Correct |
2 ms |
8540 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
2 ms |
8540 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
55900 KB |
Output is correct |
15 |
Correct |
85 ms |
66268 KB |
Output is correct |
16 |
Correct |
6 ms |
6748 KB |
Output is correct |
17 |
Correct |
19 ms |
16988 KB |
Output is correct |
18 |
Correct |
24 ms |
29276 KB |
Output is correct |
19 |
Correct |
97 ms |
70236 KB |
Output is correct |
20 |
Correct |
78 ms |
58064 KB |
Output is correct |
21 |
Correct |
51 ms |
39592 KB |
Output is correct |
22 |
Correct |
51 ms |
51800 KB |
Output is correct |
23 |
Correct |
32 ms |
70484 KB |
Output is correct |
24 |
Correct |
129 ms |
70996 KB |
Output is correct |
25 |
Correct |
98 ms |
62044 KB |
Output is correct |
26 |
Correct |
113 ms |
68340 KB |
Output is correct |
27 |
Correct |
134 ms |
70396 KB |
Output is correct |