Submission #426246

# Submission time Handle Problem Language Result Execution time Memory
426246 2021-06-13T15:45:48 Z Amylopectin Journey (NOI18_journey) C++14
20 / 100
2 ms 332 KB
#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

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 time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 2 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 2 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -