提交时间:2023-11-26 21:23:45
运行 ID: 112504
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n, m; cin >> n >> m; vector<vector<int>> a(n, vector<int>(m)); vector<vector<ll>> f(n, vector<ll>(m,0)); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) cin >> a[i][j]; } f[0][0] = 1; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(i-1 >=0 && a[i-1][j] == 0) { f[i][j] += f[i-1][j]; } if(j-1 >= 0 && a[i][j-1] == 0) { f[i][j] += f[i][j-1]; } } } cout << f[n-1][m-1] << '\n'; return 0; }