# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
634897 | 2022-08-25T08:20:50 Z | vendx_greyback | Jump (BOI06_jump) | C++14 | 10 ms | 1140 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define all(x) (x).begin(),(x).end() typedef pair<int,int> ppi; typedef vector<int> vi; typedef vector<vector<int>> vvi; string add(string num1, string num2){ while(num1.size() < num2.size()) num1.push_back('0'); while(num1.size() > num2.size()) num2.push_back('0'); string ans; int carry = 0; for(int i = 0; i < num1.size(); i++){ int curr = (num1[i] - '0') + (num2[i] - '0') + carry; ans.push_back((curr % 10) + '0'); carry = curr / 10; } if(carry) ans.push_back(carry + '0'); return ans; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin>>n; int grid[n][n]; for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin>>grid[i][j]; string dp[n][n]; for(int i = n-1; i >= 0; i--){ for(int j = n-1; j >= 0; j--){ if(i == n-1 && j == n-1){ dp[i][j] = "1"; continue; } dp[i][j] = "0"; if(i + grid[i][j] < n) dp[i][j] = add(dp[i][j], dp[i + grid[i][j]][j]); if(j + grid[i][j] < n) dp[i][j] = add(dp[i][j], dp[i][j + grid[i][j]]); } } reverse(all(dp[0][0])); cout<<dp[0][0]; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 2 ms | 468 KB | Output is correct |
16 | Correct | 6 ms | 724 KB | Output is correct |
17 | Correct | 4 ms | 596 KB | Output is correct |
18 | Correct | 7 ms | 852 KB | Output is correct |
19 | Correct | 6 ms | 724 KB | Output is correct |
20 | Correct | 10 ms | 1140 KB | Output is correct |