Submission #199459

#TimeUsernameProblemLanguageResultExecution timeMemory
199459TadijaSebezJump (BOI06_jump)C++11
100 / 100
27 ms5624 KiB
#include <bits/stdc++.h> using namespace std; const int N=105; int a[N][N],n,m; bool was[N][N]; struct Number { int c[N]; void init(){ for(int i=0;i<N;i++) c[i]=0;} Number(){ init();} void push(){ for(int i=0;i<N-1;i++) c[i+1]+=c[i]/10,c[i]%=10;} Number(int x){ init();c[0]=x;push();} void print() { int ptr=N-1; while(ptr>0 && c[ptr]==0) ptr--; for(int i=ptr;i>=0;i--) printf("%i",c[i]); printf("\n"); } }; Number operator + (Number a, Number b) { Number ans; for(int i=0;i<N;i++) ans.c[i]=a.c[i]+b.c[i]; ans.push(); return ans; } Number dp[N][N]; Number DP(int x, int y) { if(x==n && y==m) return Number(1); if(was[x][y]) return dp[x][y]; was[x][y]=1; if(a[x][y]==0) return dp[x][y]=Number(0); dp[x][y].init(); if(x+a[x][y]<=n) dp[x][y]=dp[x][y]+DP(x+a[x][y],y); if(y+a[x][y]<=m) dp[x][y]=dp[x][y]+DP(x,y+a[x][y]); //printf("%i %i: ",x,y); //dp[x][y].print(); return dp[x][y]; } int main() { scanf("%i",&n); m=n; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%i",&a[i][j]); DP(1,1).print(); return 0; }

Compilation message (stderr)

jump.cpp: In function 'int main()':
jump.cpp:44:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i",&n);
  ~~~~~^~~~~~~~~
jump.cpp:46:51: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%i",&a[i][j]);
                                              ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...