Submission #426246

#TimeUsernameProblemLanguageResultExecution timeMemory
426246AmylopectinJourney (NOI18_journey)C++14
20 / 100
2 ms332 KiB
#include <iostream> #include <stdio.h> using namespace std; const int mxn = 1e4 + 10,mxm = 410,mxi = 5e8 + 1; struct pat { int to,tim; }; struct pat pa[mxn][mxm] = {}; int dp[mxm][mxn] = {}; int main() { int i,j,n,m,h,f,t,cti,k,o,fn; scanf("%d %d %d",&n,&m,&h); for(i=0; i<n-1; i++) { for(j=0; j<h; j++) { scanf("%d %d",&t,&cti); pa[i][j] = {t,cti}; } } dp[0][0] = 1; for(i=0; i<m; i++) { for(j=0; j<n-1; j++) { if(i > 0) dp[i][j] += dp[i-1][j]; if(dp[i][j] > mxi) { dp[i][j] = mxi; } for(k=0; k<h; k++) { fn = pa[j][k].to; cti = pa[j][k].tim; if(i + cti < m && fn != 0) { dp[i+cti][fn] += dp[i][j]; if(dp[i+cti][fn] > mxi) { dp[i+cti][fn] = mxi; } } } } // if(i > 0) // { // dp[i][n-1] += dp[i-1][n-1]; // } printf("%d\n",dp[i][n-1]); } return 0; }

Compilation message (stderr)

journey.cpp: In function 'int main()':
journey.cpp:13:19: warning: unused variable 'f' [-Wunused-variable]
   13 |     int i,j,n,m,h,f,t,cti,k,o,fn;
      |                   ^
journey.cpp:13:29: warning: unused variable 'o' [-Wunused-variable]
   13 |     int i,j,n,m,h,f,t,cti,k,o,fn;
      |                             ^
journey.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d %d %d",&n,&m,&h);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
journey.cpp:19:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |             scanf("%d %d",&t,&cti);
      |             ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...