# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
226610 | MKopchev | Jump (BOI06_jump) | C++14 | 20 ms | 2176 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;
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |