Submission #531157

#TimeUsernameProblemLanguageResultExecution timeMemory
531157sidonJump (BOI06_jump)C++17
100 / 100
6 ms2128 KiB
#include <bits/stdc++.h> using namespace std; struct num { vector<int> v; num(int n = 0) : v({n}) {} void operator+=(const num &x) { int cur = 0, j = size(x.v); for(int i = 0; i < j || cur; ++i) { if(i < j) cur += x.v[i]; if(int(size(v)) == i) v.push_back(0); cur += v[i]; v[i] = cur % 10; cur /= 10; } } void print() { for(int i = size(v); i--; ) cout << v[i]; } }; int main() { ios::sync_with_stdio(0), cin.tie(0); int n; cin >> n; int a[n][n]; num b[n][n] {}; for(int i = 0; i < n; ++i) for(int &j : a[i]) cin >> j; b[0][0] = num(1); for(int i = 0; i < n; ++i) { for(int j = 0; j < n; ++j) { if(i == n-1 && j == n-1) b[i][j].print(); if(i + a[i][j] < n) b[i + a[i][j]][j] += b[i][j]; if(j + a[i][j] < n) b[i][j + a[i][j]] += b[i][j]; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...