Submission #17396213


Source Code Expand

Copy
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

using ll = long long;

ll x[50010], y[50010], z[50010], dp[105][105][105];

int main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++) {
		ll a, b, c, w; cin >> a >> b >> c >> w;
		dp[a][b][c] = max(dp[a][b][c], w);
	}
	for (int i = 0; i < m; i++)cin >> x[i] >> y[i] >> z[i];
	for (int i = 0; i < 105; i++)for (int j = 0; j < 105; j++)for (int k = 0; k < 105; k++) {
		dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
		dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
		dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j][k]);
	}
	for (int i = 0; i < m; i++) {
		cout << dp[x[i]][y[i]][z[i]] << endl;
	}

	return 0;
}

Submission Info

Submission Time
Task C - Optimal Recommendations
User nekosun
Language C++ (GCC 9.2.1)
Score 0
Code Size 735 Byte
Status
Exec Time 166 ms
Memory 13840 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:20:19: warning: iteration 104 invokes undefined behavior [-Waggressive-loop-optimizations]
   20 |   dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j][k]);
      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Main.cpp:17:78: note: within this loop
   17 |  for (int i = 0; i < 105; i++)for (int j = 0; j < 105; j++)for (int k = 0; k < 105; k++) {
      |                                                                            ~~^~~~~

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
× 3
× 5
× 16
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 166 ms 13532 KB
10-random-01.txt 114 ms 12428 KB
10-random-02.txt 125 ms 13044 KB
10-random-03.txt 138 ms 13220 KB
10-random-04.txt 137 ms 12468 KB
20-absW-00.txt 135 ms 13840 KB
20-absW-01.txt 20 ms 12576 KB
20-absW-02.txt 77 ms 12952 KB
20-absW-03.txt 117 ms 13684 KB
20-absW-04.txt 53 ms 12852 KB
30-balance-00.txt 160 ms 13528 KB
30-balance-01.txt 15 ms 12576 KB
30-balance-02.txt 117 ms 12720 KB
30-balance-03.txt 148 ms 12764 KB
30-balance-04.txt 129 ms 13412 KB
40-limit_dim-00.txt 162 ms 13508 KB
40-limit_dim-01.txt 164 ms 13528 KB
40-limit_dim-02.txt 160 ms 13548 KB
40-limit_dim-03.txt 160 ms 13412 KB
40-limit_dim-04.txt 163 ms 13544 KB
40-limit_dim-05.txt 161 ms 13524 KB
40-limit_dim-06.txt 162 ms 13492 KB
Corner1.txt 15 ms 12580 KB
Sample1.txt 16 ms 12720 KB