Submission #226610

#TimeUsernameProblemLanguageResultExecution timeMemory
226610MKopchevJump (BOI06_jump)C++14
100 / 100
20 ms2176 KiB
#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)

jump.cpp: In function 'std::vector<int> add(std::vector<int>, std::vector<int>)':
jump.cpp:18:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(i<a.size())ret[i]+=a[i];
            ~^~~~~~~~~
jump.cpp:19:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(i<b.size())ret[i]+=b[i];
            ~^~~~~~~~~
jump.cpp:23:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<ret.size()-1;i++)
                 ~^~~~~~~~~~~~~
jump.cpp: In function 'int main()':
jump.cpp:42:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i",&n);
     ~~~~~^~~~~~~~~
jump.cpp:45:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%i",&inp[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...