#include <bits/stdc++.h>
using namespace std;
struct bigint{
vector<int> d;
bigint(){
}
bigint(int x){
while (x > 0){
d.push_back(x % 10);
x /= 10;
}
if (d.empty()){
d.push_back(0);
}
}
int operator [](int k){
return d[k];
}
int size(){
return d.size();
}
};
ostream& operator <<(ostream& os, bigint x){
int N = x.size();
for (int i = N - 1; i >= 0; i--){
os << x[i];
}
return os;
}
bigint operator +(bigint A, bigint B){
int N1 = A.size();
int N2 = B.size();
int N = max(N1, N2) + 1;
bigint C;
C.d = vector<int>(N, 0);
for (int i = 0; i < N1; i++){
C.d[i] += A[i];
}
for (int i = 0; i < N2; i++){
C.d[i] += B[i];
}
for (int i = 0; i < N - 1; i++){
if (C[i] >= 10){
C.d[i + 1]++;
C.d[i] -= 10;
}
}
if (C.size() >= 2 && C[N - 1] == 0){
C.d.pop_back();
}
return C;
}
int main(){
int n;
cin >> n;
vector<vector<int>> A(n, vector<int>(n));
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
cin >> A[i][j];
}
}
vector<vector<bigint>> dp(n, vector<bigint>(n, 0));
dp[0][0] = 1;
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
if (i + A[i][j] < n){
dp[i + A[i][j]][j] = dp[i + A[i][j]][j] + dp[i][j];
}
if (j + A[i][j] < n){
dp[i][j + A[i][j]] = dp[i][j + A[i][j]] + dp[i][j];
};
}
}
cout << dp[n - 1][n - 1] << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
296 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
14 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
15 |
Incorrect |
2 ms |
596 KB |
Output isn't correct |
16 |
Incorrect |
5 ms |
1108 KB |
Output isn't correct |
17 |
Incorrect |
4 ms |
852 KB |
Output isn't correct |
18 |
Incorrect |
6 ms |
1336 KB |
Output isn't correct |
19 |
Incorrect |
5 ms |
1108 KB |
Output isn't correct |
20 |
Incorrect |
7 ms |
1748 KB |
Output isn't correct |