# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
496003 | vulpes | Jump (BOI06_jump) | C++17 | 8 ms | 1648 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
struct number {
vector<int> a;
number() {
a = {0};
}
number operator+(const number &x) {
number y; y.a.resize(max(x.a.size(), a.size()) + 1);
for (int i = 0; i < max(x.a.size(), a.size()); i++) {
int f = (i < x.a.size() ? x.a[i] : 0);
int s = (i < a.size() ? a[i] : 0);
y.a[i] += f + s;
y.a[i + 1] += y.a[i] / 10;
y.a[i] %= 10;
}
while (y.a.size() > 1 && !y.a.back()) {
y.a.pop_back();
}
return y;
}
};
void print(number x) {
for (int i = x.a.size(); i; i--) {
cout << x.a[i - 1];
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
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<number>> d(n, vector<number>(n));
d[0][0].a = {1};
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - (i == n - 1); j++) {
if (i + a[i][j] < n) {
d[i + a[i][j]][j] = d[i + a[i][j]][j] + d[i][j];
}
if (j + a[i][j] < n) {
d[i][j + a[i][j]] = d[i][j + a[i][j]] + d[i][j];
}
}
}
print(d[n - 1][n - 1]);
return cout << endl, 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |