Algorithm

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub yosupo06/Algorithm

:heavy_check_mark: src/graph/csr.hpp

Required by

Verified with

Code

#pragma once

struct CSR {
    V<int> to, start;
    CSR() {}
    CSR(int n, const V<pair<int, int>>& edges) {
        start = V<int>(n + 1);
        for (auto e : edges) {
            start[e.first]++;
        }
        for (int i = 1; i <= n; i++) {
            start[i] += start[i - 1];
        }
        to = V<int>(start.back());
        for (auto e : edges) {
            to[start[e.first] - 1] = e.second;
            start[e.first]--;
        }
    }
};
#line 2 "src/graph/csr.hpp"

struct CSR {
    V<int> to, start;
    CSR() {}
    CSR(int n, const V<pair<int, int>>& edges) {
        start = V<int>(n + 1);
        for (auto e : edges) {
            start[e.first]++;
        }
        for (int i = 1; i <= n; i++) {
            start[i] += start[i - 1];
        }
        to = V<int>(start.back());
        for (auto e : edges) {
            to[start[e.first] - 1] = e.second;
            start[e.first]--;
        }
    }
};
Back to top page