Submission #19407431


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]==0)
                {
                    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 1797 Byte
Status WA
Exec Time 51 ms
Memory 6252 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 51 ms 6212 KB
10-random-01.txt AC 13 ms 5840 KB
10-random-02.txt WA 30 ms 6120 KB
10-random-03.txt WA 33 ms 6152 KB
10-random-04.txt WA 31 ms 5940 KB
20-absW-00.txt WA 46 ms 6196 KB
20-absW-01.txt AC 10 ms 5844 KB
20-absW-02.txt WA 33 ms 6024 KB
20-absW-03.txt WA 36 ms 6144 KB
20-absW-04.txt WA 18 ms 6104 KB
30-balance-00.txt WA 50 ms 6252 KB
30-balance-01.txt AC 12 ms 5924 KB
30-balance-02.txt WA 23 ms 6068 KB
30-balance-03.txt WA 38 ms 6044 KB
30-balance-04.txt WA 33 ms 6220 KB
40-limit_dim-00.txt WA 42 ms 6204 KB
40-limit_dim-01.txt WA 44 ms 6200 KB
40-limit_dim-02.txt WA 43 ms 6168 KB
40-limit_dim-03.txt WA 45 ms 6192 KB
40-limit_dim-04.txt WA 43 ms 6192 KB
40-limit_dim-05.txt WA 45 ms 6168 KB
40-limit_dim-06.txt WA 45 ms 6252 KB
Corner1.txt WA 11 ms 5836 KB
Sample1.txt AC 10 ms 5884 KB