#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;
void add (string &a, string &b) {
bool carry = 0;
int n = max(a.size(),b.size());
a.resize(n,'0'), b.resize(n,'0');
rep (i,0,n-1) {
int sum = a[i]+b[i]+carry-2*'0';
carry = 0;
if (sum>=10) {
carry = 1;
sum -= 10;
}
a[i] = char('0'+sum);
}
cout << "= " << a << endl;
if (carry) a += '1';
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
int a[n][n];
string dp[n][n];
rep (i,0,n-1) {
rep (j,0,n-1) {
cin >> a[i][j];
dp[i][j] = "0";
}
}
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) add(dp[i+a[i][j]][j], dp[i][j]);
if (j+a[i][j]<n) add(dp[i][j+a[i][j]], dp[i][j]);
}
}
reverse(all(dp[n-1][n-1]));
cout << dp[n-1][n-1] << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
204 KB |
Output isn't correct |
8 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
9 |
Incorrect |
4 ms |
332 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
204 KB |
Output isn't correct |
11 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
12 |
Incorrect |
4 ms |
360 KB |
Output isn't correct |
13 |
Incorrect |
4 ms |
332 KB |
Output isn't correct |
14 |
Incorrect |
4 ms |
372 KB |
Output isn't correct |
15 |
Incorrect |
12 ms |
488 KB |
Output isn't correct |
16 |
Incorrect |
24 ms |
1024 KB |
Output isn't correct |
17 |
Incorrect |
21 ms |
752 KB |
Output isn't correct |
18 |
Incorrect |
31 ms |
1288 KB |
Output isn't correct |
19 |
Incorrect |
28 ms |
972 KB |
Output isn't correct |
20 |
Incorrect |
38 ms |
1568 KB |
Output isn't correct |