# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1116438 |
2024-11-21T16:15:23 Z |
YugiHacker |
Tents (JOI18_tents) |
C++17 |
|
103 ms |
102356 KB |
/*
www.youtube.com/YugiHackerChannel
linktr.ee/YugiHacker
*/
#include<bits/stdc++.h>
#define el cout<<"\n"
#define f0(i,n) for(int i=0;i<n;++i)
#define f1(i,n) for(int i=1;i<=n;++i)
#define maxn 5003
#define MOD 1000000007
using namespace std;
long long f[5003][5003];
int n, m;
main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// freopen("flagger.inp", "r", stdin);
// freopen("flagger.out", "w", stdout);
cin >> n >> m;
f0 (i, max(n, m) + 1) f[0][i] = f[i][0] = 1;
f1 (i, n) f1 (j, m)
{
f[i][j] = f[i-1][j];
(f[i][j] += 4 * f[i-1][j-1] * j) %= MOD;
if (i >= 2) (f[i][j] += f[i-2][j-1] * (i-1) * j) %= MOD;
if (j >= 2) (f[i][j] += f[i-1][j-2] * j * (j-1) / 2) %= MOD;
}
cout << (f[n][m] - 1 + MOD) % MOD;
}
Compilation message
tents.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
15 | main()
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
2 ms |
8528 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
8528 KB |
Output is correct |
5 |
Correct |
2 ms |
10576 KB |
Output is correct |
6 |
Correct |
2 ms |
10576 KB |
Output is correct |
7 |
Correct |
2 ms |
10576 KB |
Output is correct |
8 |
Correct |
2 ms |
10576 KB |
Output is correct |
9 |
Correct |
2 ms |
6480 KB |
Output is correct |
10 |
Correct |
2 ms |
12800 KB |
Output is correct |
11 |
Correct |
2 ms |
12792 KB |
Output is correct |
12 |
Correct |
2 ms |
12624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
2 ms |
8528 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
8528 KB |
Output is correct |
5 |
Correct |
2 ms |
10576 KB |
Output is correct |
6 |
Correct |
2 ms |
10576 KB |
Output is correct |
7 |
Correct |
2 ms |
10576 KB |
Output is correct |
8 |
Correct |
2 ms |
10576 KB |
Output is correct |
9 |
Correct |
2 ms |
6480 KB |
Output is correct |
10 |
Correct |
2 ms |
12800 KB |
Output is correct |
11 |
Correct |
2 ms |
12792 KB |
Output is correct |
12 |
Correct |
2 ms |
12624 KB |
Output is correct |
13 |
Correct |
7 ms |
59472 KB |
Output is correct |
14 |
Correct |
8 ms |
57680 KB |
Output is correct |
15 |
Correct |
56 ms |
82520 KB |
Output is correct |
16 |
Correct |
9 ms |
59984 KB |
Output is correct |
17 |
Correct |
15 ms |
59384 KB |
Output is correct |
18 |
Correct |
16 ms |
53888 KB |
Output is correct |
19 |
Correct |
67 ms |
87008 KB |
Output is correct |
20 |
Correct |
55 ms |
78152 KB |
Output is correct |
21 |
Correct |
35 ms |
62280 KB |
Output is correct |
22 |
Correct |
38 ms |
69004 KB |
Output is correct |
23 |
Correct |
25 ms |
74828 KB |
Output is correct |
24 |
Correct |
91 ms |
102356 KB |
Output is correct |
25 |
Correct |
69 ms |
86600 KB |
Output is correct |
26 |
Correct |
73 ms |
94280 KB |
Output is correct |
27 |
Correct |
103 ms |
92488 KB |
Output is correct |