Submission #19407479


Source Code Expand

Copy
#include <stdio.h>
#include <stdlib.h>

int main();

int main()
{
    int N, M, ***dp, *x, *y, *z, a, b, c,w;
    scanf("%d %d", &N, &M);
    dp=malloc(101*sizeof(int**));
    for (int i=0; i<=100; i++)
    {
        dp[i]=malloc(101*sizeof(int*));
        for (int j=0; j<=100; j++)
        {
            dp[i][j]=malloc(101*sizeof(int));
        }
    } 
    for (int i=0; i<=100; i++)
    {
        for (int j=0; j<=100; j++)
        {
            for (int k=0; k<=100; k++)
            {
                dp[i][j][k]=0;
            }
        }
    } 
    for (int i=0; i<N; i++)
    {
        scanf("%d %d %d %d", &a, &b, &c, &w);
        dp[a][b][c]=w;
    }
    x=malloc((M+1)*sizeof(int));
    y=malloc((M+1)*sizeof(int));
    z=malloc((M+1)*sizeof(int));
    for (int i=1; i<=M; i++)
    {
        scanf("%d %d %d", &x[i], &y[i], &z[i]);
    }
    for (int i=1; i<=100; i++)
    {
        for (int j=1; j<=100; j++)
        {
            for (int k=1; k<=100; k++)
            {
                if(dp[i][j][k]<dp[i-1][j][k])
                {
                    dp[i][j][k]=dp[i-1][j][k];
                }
                if (dp[i][j][k]<dp[i][j-1][k])
                {
                    dp[i][j][k]=dp[i][j-1][k];
                }
                if (dp[i][j][k]<dp[i][j][k-1])
                {
                    dp[i][j][k]=dp[i][j][k-1];
                } 
            }
        }
    }
    for (int i=1; i<=M; i++)
    {
        printf("%d\n",dp[x[i]][y[i]][z[i]]);
    }
    free(x);free(y);free(z);
    for (int i=0; i<=100; i++)
    {
        for (int j=0; j<=100; j++)
        {
            free(dp[i][j]);
        }
        free(dp[i]);
    }
    free(dp);
    return 0;
}

Submission Info

Submission Time
Task C - Optimal Recommendations
User Keita_S
Language C (GCC 9.2.1)
Score 0
Code Size 1773 Byte
Status WA
Exec Time 52 ms
Memory 6228 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:9:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
    9 |     scanf("%d %d", &N, &M);
      |     ^~~~~~~~~~~~~~~~~~~~~~
./Main.c:31:9: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   31 |         scanf("%d %d %d %d", &a, &b, &c, &w);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Main.c:39:9: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   39 |         scanf("%d %d %d", &x[i], &y[i], &z[i]);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 4
WA × 20
Set Name Test Cases
All 10-random-00.txt, 10-random-01.txt, 10-random-02.txt, 10-random-03.txt, 10-random-04.txt, 20-absW-00.txt, 20-absW-01.txt, 20-absW-02.txt, 20-absW-03.txt, 20-absW-04.txt, 30-balance-00.txt, 30-balance-01.txt, 30-balance-02.txt, 30-balance-03.txt, 30-balance-04.txt, 40-limit_dim-00.txt, 40-limit_dim-01.txt, 40-limit_dim-02.txt, 40-limit_dim-03.txt, 40-limit_dim-04.txt, 40-limit_dim-05.txt, 40-limit_dim-06.txt, Corner1.txt, Sample1.txt
Case Name Status Exec Time Memory
10-random-00.txt WA 52 ms 6224 KB
10-random-01.txt AC 12 ms 5848 KB
10-random-02.txt WA 30 ms 6048 KB
10-random-03.txt WA 36 ms 6092 KB
10-random-04.txt WA 33 ms 5904 KB
20-absW-00.txt WA 52 ms 6228 KB
20-absW-01.txt AC 11 ms 5896 KB
20-absW-02.txt WA 36 ms 6084 KB
20-absW-03.txt WA 41 ms 6128 KB
20-absW-04.txt WA 27 ms 6020 KB
30-balance-00.txt WA 50 ms 6164 KB
30-balance-01.txt AC 12 ms 5848 KB
30-balance-02.txt WA 22 ms 6108 KB
30-balance-03.txt WA 40 ms 6084 KB
30-balance-04.txt WA 29 ms 6124 KB
40-limit_dim-00.txt WA 45 ms 6172 KB
40-limit_dim-01.txt WA 46 ms 6176 KB
40-limit_dim-02.txt WA 46 ms 6176 KB
40-limit_dim-03.txt WA 49 ms 6164 KB
40-limit_dim-04.txt WA 45 ms 6164 KB
40-limit_dim-05.txt WA 43 ms 6168 KB
40-limit_dim-06.txt WA 46 ms 6168 KB
Corner1.txt WA 14 ms 5840 KB
Sample1.txt AC 11 ms 5844 KB