# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1104114 | Kirill22 | Jump (BOI06_jump) | C++17 | 5 ms | 2384 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 Int {
vector<int> a;
Int(int x = 0) : a(1, x) {}
Int& operator+=(const Int& Other) {
if (a.size() < Other.a.size()) {
a.resize(Other.a.size());
}
int rem = 0;
for (int i = 0; i < (int) a.size() || rem; i++) {
if ((int) a.size() == i) {
a.push_back(0);
}
rem += a[i];
if (i < (int) Other.a.size()) {
rem += Other.a[i];
}
a[i] = rem % 10;
rem /= 10;
}
return *this;
}
void print() {
if (a.empty() || (int) a.size() == 1 && a[0] == 0) {
cout << 0 << '\n';
} else {
std::reverse(a.begin(), a.end());
for (auto& c : a) {
cout << c;
}
}
}
};
const int N = 100 + 22;
Int dp[N][N];
int a[N][N];
void solve() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> a[i][j];
}
}
dp[0][0] = Int(1);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
for (int i2 = 0; i2 < i; i2++) {
if (a[i2][j] == i - i2) {
dp[i][j] += dp[i2][j];
}
}
for (int j2 = 0; j2 < j; j2++) {
if (a[i][j2] == j - j2) {
dp[i][j] += dp[i][j2];
}
}
}
}
dp[n - 1][n - 1].print();
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |