# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
701410 |
2023-02-21T07:58:53 Z |
fatemetmhr |
Tents (JOI18_tents) |
C++17 |
|
227 ms |
91952 KB |
// ~ Be Name Khoda ~
#include <bits/stdc++.h>
//#pragma GCC optimize ("Ofast")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,O3")
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const int maxn = 1e6 + 10;
const int maxn5 = 3e3 + 10;
const int maxnt = 1.2e6 + 10;
const int maxn3 = 1e3 + 10;
const int mod = 1e9 + 7;
const ll inf = 1e18;
int tak[maxn5][maxn5], dbgr[maxn5][maxn5];
int ent[maxn5][maxn5];
inline void fix(int &a){
if(a < 0)
a += mod;
if(a >= mod)
a -= mod;
}
int main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
int n, m; cin >> n >> m;
for(int i = 0; i <= n; i++) for(int j = 0; j <= m; j++){
if(min(i, j) == 0){
tak[i][j] = 1;
continue;
}
fix(tak[i][j] = tak[i - 1][j] + tak[i - 1][j - 1] * 4LL * j % mod);
}
for(int i = 0; i <= max(n, m); i++){
dbgr[i][0] = 1;
for(int j = 1; j * 2 <= i; j++)
fix(dbgr[i][j] = dbgr[i - 1][j] + (dbgr[i - 2][j - 1] * (i - 1LL) * j % mod));
}
ent[0][0] = 1;
for(int i = 1; i < maxn5; i++){
ent[i][0] = 1;
for(int j = 1; j < maxn5; j++)
fix(ent[i][j] = ent[i - 1][j] + ent[i - 1][j - 1]);
}
int ans = 0;
for(int i = 0; i <= n; i++) for(int j = 0; j <= m; j++) if(n >= i + 2 * j && m >= j + 2 * i){
ll cur = ll(ent[n][i]) * ent[m][j] % mod;
cur = cur * dbgr[m - j][i] % mod;
//cout << i << ' ' << j << ' ' << cur << endl;
cur = cur * dbgr[n - i][j] % mod;
//cout << i << ' ' << j << ' ' << cur << endl;
cur = cur * tak[n - i - 2 * j][m - j - 2 * i] % mod;
fix(ans += cur);
//cout << i << ' ' << j << ' ' << cur << ' ' << tak[n - i - 2 * j][m - j - 2 * i] << endl;
}
fix(--ans);
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
35788 KB |
Output is correct |
2 |
Correct |
36 ms |
36428 KB |
Output is correct |
3 |
Correct |
36 ms |
36124 KB |
Output is correct |
4 |
Correct |
37 ms |
37460 KB |
Output is correct |
5 |
Correct |
37 ms |
37068 KB |
Output is correct |
6 |
Correct |
38 ms |
37708 KB |
Output is correct |
7 |
Correct |
49 ms |
37132 KB |
Output is correct |
8 |
Correct |
41 ms |
37832 KB |
Output is correct |
9 |
Correct |
37 ms |
36684 KB |
Output is correct |
10 |
Correct |
39 ms |
38192 KB |
Output is correct |
11 |
Correct |
37 ms |
37068 KB |
Output is correct |
12 |
Correct |
41 ms |
38548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
35788 KB |
Output is correct |
2 |
Correct |
36 ms |
36428 KB |
Output is correct |
3 |
Correct |
36 ms |
36124 KB |
Output is correct |
4 |
Correct |
37 ms |
37460 KB |
Output is correct |
5 |
Correct |
37 ms |
37068 KB |
Output is correct |
6 |
Correct |
38 ms |
37708 KB |
Output is correct |
7 |
Correct |
49 ms |
37132 KB |
Output is correct |
8 |
Correct |
41 ms |
37832 KB |
Output is correct |
9 |
Correct |
37 ms |
36684 KB |
Output is correct |
10 |
Correct |
39 ms |
38192 KB |
Output is correct |
11 |
Correct |
37 ms |
37068 KB |
Output is correct |
12 |
Correct |
41 ms |
38548 KB |
Output is correct |
13 |
Correct |
48 ms |
46404 KB |
Output is correct |
14 |
Correct |
55 ms |
59456 KB |
Output is correct |
15 |
Correct |
156 ms |
86880 KB |
Output is correct |
16 |
Correct |
50 ms |
46660 KB |
Output is correct |
17 |
Correct |
65 ms |
53812 KB |
Output is correct |
18 |
Correct |
68 ms |
53508 KB |
Output is correct |
19 |
Correct |
167 ms |
90020 KB |
Output is correct |
20 |
Correct |
142 ms |
80368 KB |
Output is correct |
21 |
Correct |
106 ms |
67800 KB |
Output is correct |
22 |
Correct |
110 ms |
70868 KB |
Output is correct |
23 |
Correct |
93 ms |
75892 KB |
Output is correct |
24 |
Correct |
227 ms |
91952 KB |
Output is correct |
25 |
Correct |
162 ms |
83144 KB |
Output is correct |
26 |
Correct |
194 ms |
88128 KB |
Output is correct |
27 |
Correct |
212 ms |
90648 KB |
Output is correct |