Submission #19407459
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",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 |
1795 Byte |
Status |
WA |
Exec Time |
47 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 |
|
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 |
47 ms |
6252 KB |
10-random-01.txt |
WA |
10 ms |
5916 KB |
10-random-02.txt |
WA |
22 ms |
6048 KB |
10-random-03.txt |
WA |
34 ms |
6140 KB |
10-random-04.txt |
WA |
31 ms |
5924 KB |
20-absW-00.txt |
WA |
44 ms |
6184 KB |
20-absW-01.txt |
WA |
10 ms |
5924 KB |
20-absW-02.txt |
WA |
30 ms |
6044 KB |
20-absW-03.txt |
WA |
36 ms |
6136 KB |
20-absW-04.txt |
WA |
22 ms |
6032 KB |
30-balance-00.txt |
WA |
47 ms |
6200 KB |
30-balance-01.txt |
WA |
12 ms |
5880 KB |
30-balance-02.txt |
WA |
22 ms |
6128 KB |
30-balance-03.txt |
WA |
37 ms |
6028 KB |
30-balance-04.txt |
WA |
27 ms |
6168 KB |
40-limit_dim-00.txt |
WA |
44 ms |
6212 KB |
40-limit_dim-01.txt |
WA |
45 ms |
6172 KB |
40-limit_dim-02.txt |
WA |
44 ms |
6216 KB |
40-limit_dim-03.txt |
WA |
45 ms |
6208 KB |
40-limit_dim-04.txt |
WA |
42 ms |
6240 KB |
40-limit_dim-05.txt |
WA |
46 ms |
6216 KB |
40-limit_dim-06.txt |
WA |
45 ms |
6180 KB |
Corner1.txt |
WA |
10 ms |
5924 KB |
Sample1.txt |
WA |
11 ms |
5840 KB |