#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,e) for (int i = s; i <= e; ++i)
#define rrep(i,s,e) for (int i = s; i >= e; --i)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<ll> vll;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
int a[n][n];
ll dp[n][n]={};
rep (i,0,n-1) rep (j,0,n-1) cin >> a[i][j];
dp[0][0] = 1;
rep (i,0,n-1) {
rep(j,0,n-1) {
if (a[i][j]==0) continue;
if (i+a[i][j]<n) dp[i+a[i][j]][j]+=dp[i][j];
if (j+a[i][j]<n) dp[i][j+a[i][j]]+=dp[i][j];
}
}
cout << dp[n-1][n-1] << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
16 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
17 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
18 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
19 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
436 KB |
Output isn't correct |