Submission #496003

#TimeUsernameProblemLanguageResultExecution timeMemory
496003vulpesJump (BOI06_jump)C++17
100 / 100
8 ms1648 KiB
#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)

jump.cpp: In member function 'number number::operator+(const number&)':
jump.cpp:11:27: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   11 |         for (int i = 0; i < max(x.a.size(), a.size()); i++) {
      |                         ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
jump.cpp:12:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |             int f = (i < x.a.size() ? x.a[i] : 0);
      |                      ~~^~~~~~~~~~~~
jump.cpp:13:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |             int s = (i < a.size() ? a[i] : 0);
      |                      ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...