Submission #1118578

# Submission time Handle Problem Language Result Execution time Memory
1118578 2024-11-25T17:07:42 Z Error42 Restore Array (RMI19_restore) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>

using namespace std;

using ll = long long;
#define int ll

struct edge {
    int from, to, w;
};

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;

    vector<edge> edges;

    for (int i = 0; i < n; i++) {
        edges.push_back({ i, i + 1, 1 });
        edges.push_back({ i + 1, i, 0 });
    }

    for (int i = 0; i < m; i++) {
        int l, r, k, v;
        cin >> l >> r >> k >> v;

        if (v == 0) {
            // p[r + 1] - p[l] <= r - l + 1 - k
            // p[r + 1] <= p[l] + r - l + 1 - k
            edges.push_back({ l, r + 1, r - l + 1 - k });
        }
        else {
            // p[r + 1] - p[l] >= k - 1
            // p[r + 1] + 1 - k >= p[l]
            // p[l] <= p[r + 1] + 1 - k
            edges.push_back({ r + 1, l, 1 - k });
        }
    }

    vector<int> dist(n + 1, INT_MAX / 3);
    dist[0] = 0;

    bool solution_found;

    for (int i = 0; i < n + 1; i++) {
        solution_found = true;

        for (edge const& e : edges) {
            int const new_dist = dist[e.from] + e.w;

            if (new_dist < dist[e.to]) {
                dist[e.to] = new_dist;
                solution_found = false;
            }
        }

        if (solution_found)
            break;
    }

    if (!solution_found) {
        cout << "-1\n";
        return 0;
    }

    for (int i = 0; i < n; i++)
        cout << dist[i + 1] - dist[i] << " ";
    cout << "\n";
}

Compilation message

restore.cpp: In function 'int main()':
restore.cpp:44:29: error: 'INT_MAX' was not declared in this scope
   44 |     vector<int> dist(n + 1, INT_MAX / 3);
      |                             ^~~~~~~
restore.cpp:3:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    2 | #include <vector>
  +++ |+#include <climits>
    3 |