Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adamant-pwn committed Nov 21, 2024
1 parent 2ef9572 commit 0b4ecf9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions cp-algo/graph/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace cp_algo::graph {
adj.push(u, (edge_index)size(edges));
edges.push_back(e);
if constexpr (undirected) {
adj.push(e.to, size(edges));
adj.push(e.to, (edge_index)size(edges));
}
edges.push_back(e.backedge(u));
}
Expand Down Expand Up @@ -44,15 +44,14 @@ namespace cp_algo::graph {
return std::views::iota(0, n());
}
auto edges_view() const {
return std::views::filter(
std::views::iota(0, 2 * m()),
return std::views::iota(0, 2 * m()) | std::views::filter(
[](edge_index e) {return !(e % 2);}
);
}
auto const& incidence_lists() const {return adj;}
edge_t const& edge(edge_index e) const {return edges[e];}
node_index n() const {return (node_index)adj.size();}
edge_index m() const {return size(edges) / 2;}
edge_index m() const {return (edge_index)size(edges) / 2;}
private:
node_index v0;
std::vector<edge_t> edges;
Expand Down
4 changes: 2 additions & 2 deletions cp-algo/number_theory/discrete_log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ namespace cp_algo::math {
// a * b^x is periodic here
using base = dynamic_modint<>;
return base::with_mod(m, [&]() -> std::optional<uint64_t> {
size_t sqrtmod = std::max<size_t>(1, std::sqrt(m) / 2);
int sqrtmod = std::max(1, (int)std::sqrt(m) / 2);
std::unordered_map<int64_t, int> small;
base cur = a;
for(size_t i = 0; i < sqrtmod; i++) {
for(int i = 0; i < sqrtmod; i++) {
small[cur.getr()] = i;
cur *= b;
}
Expand Down
2 changes: 1 addition & 1 deletion cp-algo/number_theory/euler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "factorize.hpp"
namespace cp_algo::math {
int64_t euler_phi(int64_t m) {
auto primes = factorize(m);
auto primes = to<std::vector>(factorize(m));
std::ranges::sort(primes);
auto [from, to] = std::ranges::unique(primes);
primes.erase(from, to);
Expand Down

0 comments on commit 0b4ecf9

Please sign in to comment.