# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
888126 |
2023-12-16T05:32:28 Z |
vjudge1 |
Tents (JOI18_tents) |
C++17 |
|
61 ms |
72284 KB |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// Ofast, O0, O1, O2, O3, unroll-loops, fast-math, trapv
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define Mp make_pair
#define sep ' '
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define kill(res) cout << res << '\n', exit(0);
#define set_dec(x) cout << fixed << setprecision(x);
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r", stdin) ; freopen("output.txt", "w", stdout);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 3e3 + 50;
const ll Mod = 1e9 + 7;
ll n, m, dp[N][N], inv2;
ll power(ll a, ll b, ll md = Mod){
ll ans = 1;
for(; b; b /= 2, a = a * a % md){
if(b % 2) ans = ans * a % md;
}
return ans;
}
ll c2(ll x){
return x * (x-1) % Mod * inv2 % Mod;
}
int main(){
fast_io;
inv2 = power(2, Mod-2);
cin >> n >> m;
dp[0][0] = 1;
for(int i = 1; i <= n; i++) dp[i][0] = 1;
for(int j = 1; j <= m; j++) dp[0][j] = 1;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
dp[i][j] = (dp[i-1][j] + 4 * dp[i-1][j-1] * j) % Mod;
if(i > 1) dp[i][j] = (dp[i][j] + dp[i-2][j-1] * j * (i-1)) % Mod;
if(j > 1) dp[i][j] = (dp[i][j] + dp[i-1][j-2] * c2(j)) % Mod;
}
}
cout << (dp[n][m] - 1 + Mod) % 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 |
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 |
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 |
2 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 |
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 |
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 |
2 ms |
8540 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
12 ms |
55764 KB |
Output is correct |
15 |
Correct |
41 ms |
68308 KB |
Output is correct |
16 |
Correct |
3 ms |
6744 KB |
Output is correct |
17 |
Correct |
9 ms |
16988 KB |
Output is correct |
18 |
Correct |
13 ms |
29188 KB |
Output is correct |
19 |
Correct |
46 ms |
70368 KB |
Output is correct |
20 |
Correct |
37 ms |
59996 KB |
Output is correct |
21 |
Correct |
25 ms |
41564 KB |
Output is correct |
22 |
Correct |
26 ms |
53852 KB |
Output is correct |
23 |
Correct |
19 ms |
72224 KB |
Output is correct |
24 |
Correct |
61 ms |
72284 KB |
Output is correct |
25 |
Correct |
48 ms |
64092 KB |
Output is correct |
26 |
Correct |
52 ms |
68344 KB |
Output is correct |
27 |
Correct |
61 ms |
70488 KB |
Output is correct |