Submission #794565

# Submission time Handle Problem Language Result Execution time Memory
794565 2023-07-26T15:48:10 Z Sandarach151 Tents (JOI18_tents) C++17
100 / 100
56 ms 70688 KB
#include<bits/stdc++.h>
using namespace std;

const long long MODD = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long h, w;
	cin >> h >> w;
	long long ans[h+1][w+1];
	for(long long i=0; i<=h; i++){
		ans[i][0]=1;
	}
	for(long long i=0; i<=w; i++){
		ans[0][i]=1;
	}
	for(long long i=1; i<=h; i++){
		ans[i][1]=i*4+i*(i-1)/2+1;
	}
	for(long long i=1; i<=w; i++){
		ans[1][i]=i*4+i*(i-1)/2+1;
	}
	for(long long i=2; i<=h; i++){
		for(long long j=2; j<=w; j++){
			long long caseEWN = 3*j*ans[i-1][j-1];
			long long caseSs = j*ans[i-1][j-1];
			long long caseSd = j*(i-1)*ans[i-2][j-1];
			ans[i][j]=ans[i-1][j]+j*(j-1)/2*ans[i-1][j-2]+caseEWN+caseSs+caseSd;
			ans[i][j] %= MODD;
		}
	}
	cout << ans[h][w]-1 << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 576 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 576 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 980 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 33 ms 44032 KB Output is correct
16 Correct 3 ms 3028 KB Output is correct
17 Correct 9 ms 10068 KB Output is correct
18 Correct 10 ms 12372 KB Output is correct
19 Correct 39 ms 51232 KB Output is correct
20 Correct 34 ms 41052 KB Output is correct
21 Correct 18 ms 27068 KB Output is correct
22 Correct 18 ms 26740 KB Output is correct
23 Correct 13 ms 14972 KB Output is correct
24 Correct 56 ms 70688 KB Output is correct
25 Correct 40 ms 52556 KB Output is correct
26 Correct 42 ms 60184 KB Output is correct
27 Correct 53 ms 68040 KB Output is correct