# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
998391 |
2024-06-13T19:51:16 Z |
ag_1204 |
Tents (JOI18_tents) |
C++17 |
|
73 ms |
70828 KB |
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll mod=1e9+7;
ll h,w; cin>>h>>w;
ll grid[h+1][w+1];
for (ll i=0;i<=h;i++) {
for (ll j=0;j<=w;j++) {
if (i==0 || j==0) {
grid[i][j]=1;
} else {
grid[i][j]=0;
}
}
}
for (ll i=1;i<=h;i++) {
for (ll j=1;j<=w;j++) {
grid[i][j]=grid[i-1][j];
if (j>1) {
ll k1=j*(j-1);
k1/=2;
k1*=grid[i-1][j-2];
grid[i][j]+=k1;
}
if (i>1) {
ll k2=j*(i-1);
k2*=grid[i-2][j-1];
grid[i][j]+=k2;
}
ll k=4*j;
k*=grid[i-1][j-1];
grid[i][j]+=k;
grid[i][j]%=mod;
}
}
grid[h][w]--;
cout<<grid[h][w]<<endl;
return 0;
}
# |
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 |
0 ms |
460 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 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 |
0 ms |
460 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
41 ms |
44124 KB |
Output is correct |
16 |
Correct |
3 ms |
3164 KB |
Output is correct |
17 |
Correct |
10 ms |
10168 KB |
Output is correct |
18 |
Correct |
11 ms |
12488 KB |
Output is correct |
19 |
Correct |
47 ms |
51288 KB |
Output is correct |
20 |
Correct |
42 ms |
41048 KB |
Output is correct |
21 |
Correct |
25 ms |
27224 KB |
Output is correct |
22 |
Correct |
29 ms |
26768 KB |
Output is correct |
23 |
Correct |
15 ms |
14940 KB |
Output is correct |
24 |
Correct |
73 ms |
70828 KB |
Output is correct |
25 |
Correct |
48 ms |
52560 KB |
Output is correct |
26 |
Correct |
54 ms |
60380 KB |
Output is correct |
27 |
Correct |
68 ms |
68176 KB |
Output is correct |