Submission #1216915

#TimeUsernameProblemLanguageResultExecution timeMemory
1216915takoshanavaBoxes with souvenirs (IOI15_boxes)C++20
Compilation error
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; const int INF = 1e9; vector<vector<int>> cost; vector<int> dp; int dist1(int a, int b) { return (b - a + L) % L; } int dist2(int a, int b) { return (a - b + L) % L; } int delivery(int N, int K, int L, int pos[]){ vector<vector<int>> cost; vector<int> dp; sort(pos.begin(), pos.end(), [&](int a, int b) { return dist1(0, a) < dist1(0, b); }); cost.assign(N, vector<int>(N, INF)); for (int i = 0; i < N; i++) { int far1 = 0, far2 = 0; for (int j = i; j < N && j - i + 1 <= K; j++) { far1 = max(far1, dist1(0, pos[j])); cost[i][j] = min(cost[i][j], 2 * far1); far2 = max(far2, dist2(0, pos[j])); cost[i][j] = min(cost[i][j], 2 * far2); if (j - i + 1 == K) { cost[i][j] = min(cost[i][j], L); } } } dp.assign(N + 1, INF); dp[0] = 0; for (int i = 1; i <= N; i++) { for (int j = max(0, i - K); j < i; j++) { dp[i] = min(dp[i], dp[j] + cost[j][i - 1]); } } return dp[N]; }

Compilation message (stderr)

boxes.cpp: In function 'int dist1(int, int)':
boxes.cpp:10:21: error: 'L' was not declared in this scope
   10 |     return (b - a + L) % L;
      |                     ^
boxes.cpp: In function 'int dist2(int, int)':
boxes.cpp:14:21: error: 'L' was not declared in this scope
   14 |     return (a - b + L) % L;
      |                     ^
boxes.cpp: At global scope:
boxes.cpp:17:5: error: ambiguating new declaration of 'int delivery(int, int, int, int*)'
   17 | int delivery(int N, int K, int L, int pos[]){
      |     ^~~~~~~~
In file included from boxes.cpp:1:
boxes.h:4:11: note: old declaration 'long long int delivery(int, int, int, int*)'
    4 | long long delivery(int N, int K, int L, int p[]);
      |           ^~~~~~~~
boxes.cpp: In function 'int delivery(int, int, int, int*)':
boxes.cpp:20:14: error: request for member 'begin' in 'pos', which is of non-class type 'int*'
   20 |     sort(pos.begin(), pos.end(), [&](int a, int b) {
      |              ^~~~~
boxes.cpp:20:27: error: request for member 'end' in 'pos', which is of non-class type 'int*'
   20 |     sort(pos.begin(), pos.end(), [&](int a, int b) {
      |                           ^~~