diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-02-28 23:13:39 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-02-28 23:13:39 +0800 |
commit | dc1f0c4c0096013799416664894c5194dc7e1f52 (patch) | |
tree | 2f5d235f778cd720f4c39ec3e56b77ba6d99f375 /store/works/solutions/acwing/1212.cpp | |
parent | 7299d424d90b1effb6db69e3476ddd5af72eeba4 (diff) | |
download | crupest-dc1f0c4c0096013799416664894c5194dc7e1f52.tar.gz crupest-dc1f0c4c0096013799416664894c5194dc7e1f52.tar.bz2 crupest-dc1f0c4c0096013799416664894c5194dc7e1f52.zip |
chore(store): move everything to store.
Diffstat (limited to 'store/works/solutions/acwing/1212.cpp')
-rw-r--r-- | store/works/solutions/acwing/1212.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/store/works/solutions/acwing/1212.cpp b/store/works/solutions/acwing/1212.cpp new file mode 100644 index 0000000..e60e993 --- /dev/null +++ b/store/works/solutions/acwing/1212.cpp @@ -0,0 +1,46 @@ +#include <iostream>
+
+int n, m, k;
+int v[51][51];
+int f[51][51][14][14]; // row col count max
+const int MOD = 1000000007;
+
+int main() {
+ std::ios_base::sync_with_stdio(false);
+ std::cin >> n >> m >> k;
+
+ for (int i = 1; i <= n; i++)
+ for (int j = 1; j <= m; j++) {
+ std::cin >> v[i][j];
+ v[i][j]++;
+ }
+
+ f[1][1][0][0] = 1;
+ f[1][1][1][v[1][1]] = 1;
+
+ for (int i = 1; i <= n; i++) {
+ for (int j = 1; j <= m; j++) {
+ for (int c = 0; c <= k; c++) {
+ for (int m = 0; m <= 13; m++) {
+ f[i][j][c][m] = (f[i][j][c][m] + f[i][j - 1][c][m]) % MOD;
+ f[i][j][c][m] = (f[i][j][c][m] + f[i - 1][j][c][m]) % MOD;
+
+ if (c && v[i][j] == m) {
+ for (int max = 0; max < v[i][j]; max++) {
+ f[i][j][c][m] = (f[i][j][c][m] + f[i][j - 1][c - 1][max]) % MOD;
+ f[i][j][c][m] = (f[i][j][c][m] + f[i - 1][j][c - 1][max]) % MOD;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ int result = 0;
+ for (int i = 1; i <= 13; i++)
+ result = (result + f[n][m][k][i]) % MOD;
+
+ std::cout << result;
+
+ return 0;
+}
|