# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
226610 | 2020-04-24T13:56:45 Z | MKopchev | Jump (BOI06_jump) | C++14 | 20 ms | 2176 KB |
#include<bits/stdc++.h> using namespace std; const int nmax=1e2+5; int n; int inp[nmax][nmax]; vector<int> dp[nmax][nmax]; vector<int> add(vector<int> a,vector<int> b) { int sz=max(a.size(),b.size()); vector<int> ret={}; for(int i=0;i<sz;i++) { ret.push_back(0); if(i<a.size())ret[i]+=a[i]; if(i<b.size())ret[i]+=b[i]; } ret.push_back(0); for(int i=0;i<ret.size()-1;i++) { ret[i+1]+=ret[i]/10; ret[i]=ret[i]%10; } if(ret.back()==0)ret.pop_back(); return ret; } void print(vector<int> outp) { for(int i=outp.size()-1;i>=0;i--) printf("%i",outp[i]); printf("\n"); } int main() { scanf("%i",&n); for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) scanf("%i",&inp[i][j]); for(int i=n;i>=1;i--) for(int j=n;j>=1;j--) { dp[i][j]={0}; if(i==n&&j==n){dp[i][j]={1};continue;} if(i+inp[i][j]<=n)dp[i][j]=add(dp[i][j],dp[i+inp[i][j]][j]); if(j+inp[i][j]<=n)dp[i][j]=add(dp[i][j],dp[i][j+inp[i][j]]); } print(dp[1][1]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 640 KB | Output is correct |
2 | Correct | 5 ms | 640 KB | Output is correct |
3 | Correct | 5 ms | 640 KB | Output is correct |
4 | Correct | 5 ms | 640 KB | Output is correct |
5 | Correct | 5 ms | 640 KB | Output is correct |
6 | Correct | 5 ms | 640 KB | Output is correct |
7 | Correct | 5 ms | 640 KB | Output is correct |
8 | Correct | 5 ms | 640 KB | Output is correct |
9 | Correct | 5 ms | 640 KB | Output is correct |
10 | Correct | 5 ms | 640 KB | Output is correct |
11 | Correct | 5 ms | 640 KB | Output is correct |
12 | Correct | 5 ms | 640 KB | Output is correct |
13 | Correct | 5 ms | 640 KB | Output is correct |
14 | Correct | 6 ms | 640 KB | Output is correct |
15 | Correct | 8 ms | 896 KB | Output is correct |
16 | Correct | 14 ms | 1536 KB | Output is correct |
17 | Correct | 12 ms | 1152 KB | Output is correct |
18 | Correct | 17 ms | 1792 KB | Output is correct |
19 | Correct | 16 ms | 1408 KB | Output is correct |
20 | Correct | 20 ms | 2176 KB | Output is correct |