Submission #753854

# Submission time Handle Problem Language Result Execution time Memory
753854 2023-06-06T08:25:48 Z jakobrs Stranded Far From Home (BOI22_island) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <queue>

using i64 = int64_t;

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);

    i64 n, m;
    std::cin >> n >> m;

    std::vector<i64> a(n);
    for (i64 i = 0; i < n; i++)
        std::cin >> a[i];

    std::vector<std::vector<i64>> adj(n);
    for (i64 i = 0; i < m; i++) {
        i64 u, v;
        std::cin >> u >> v;
        u--, v--;

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    std::string result;
    result.reserve(n);

    std::vector<i64> visited(n);
    for (i64 i = 0; i < n; i++) {
        struct Node {
            i64 size;
            i64 idx;

            bool operator<(const Node &rhs) const {
                return std::tie(rhs.size, idx) < std::tie(size, rhs.idx);
            }
        };

        std::priority_queue<Node> q;
        std::fill(visited.begin(), visited.end(), false);
        visited[i] = true;

        i64 mass = a[i];
        q.push(Node { .size = 0, .idx = i });

        while (!q.empty()) {
            Node node = q.top();
            if (node.size > mass) break;
            mass += node.size;

            q.pop();
            for (i64 j : adj[i]) {
                if (!visited[j]) {
                    visited[j] = true;
                    q.push(Node { .size = a[j], .idx = j });
                }
            }
        }

        result.push_back(q.empty() ? '1' : '0');
    }

    std::cout << result;
}

Compilation message

island.cpp: In member function 'bool main()::Node::operator<(const main()::Node&) const':
island.cpp:37:29: error: 'tie' is not a member of 'std'
   37 |                 return std::tie(rhs.size, idx) < std::tie(size, rhs.idx);
      |                             ^~~
island.cpp:4:1: note: 'std::tie' is defined in header '<tuple>'; did you forget to '#include <tuple>'?
    3 | #include <queue>
  +++ |+#include <tuple>
    4 | 
island.cpp:37:55: error: 'tie' is not a member of 'std'
   37 |                 return std::tie(rhs.size, idx) < std::tie(size, rhs.idx);
      |                                                       ^~~
island.cpp:37:55: note: 'std::tie' is defined in header '<tuple>'; did you forget to '#include <tuple>'?