summaryrefslogtreecommitdiff
path: root/content/graph/cycleCounting.cpp
diff options
context:
space:
mode:
authorGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 21:17:29 +0100
committerGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 21:17:29 +0100
commit1880ccb6d85c6eb79e724593457877bab431951c (patch)
tree23eddd5bd0b29b3024e170a5ef9023eda9226ab5 /content/graph/cycleCounting.cpp
parente95f59debd69ee7d45d5c966ce466d23264e1c3c (diff)
get rid of all() and sz()
Diffstat (limited to 'content/graph/cycleCounting.cpp')
-rw-r--r--content/graph/cycleCounting.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/content/graph/cycleCounting.cpp b/content/graph/cycleCounting.cpp
index 471d399..65bf1a0 100644
--- a/content/graph/cycleCounting.cpp
+++ b/content/graph/cycleCounting.cpp
@@ -9,8 +9,8 @@ struct cycles {
cycles(int n) : adj(n), seen(n), paths(n) {}
void addEdge(int u, int v) {
- adj[u].push_back({v, sz(edges)});
- adj[v].push_back({u, sz(edges)});
+ adj[u].push_back({v, ssize(edges)});
+ adj[v].push_back({u, ssize(edges)});
edges.push_back({u, v});
}
@@ -38,8 +38,8 @@ struct cycles {
bool isCycle(cycle cur) { // cycle must be constrcuted from base
if (cur.none()) return false;
- init(sz(adj)); // union find @\sourceref{datastructures/unionFind.cpp}@
- for (int i = 0; i < sz(edges); i++) {
+ init(ssize(adj)); // union find @\sourceref{datastructures/unionFind.cpp}@
+ for (int i = 0; i < ssize(edges); i++) {
if (cur[i]) {
cur[i] = false;
if (findSet(edges[i].first) ==
@@ -50,12 +50,12 @@ struct cycles {
}
int count() {
- for (int i = 0; i < sz(adj); i++) findBase(i);
- assert(sz(base) < 30);
+ for (int i = 0; i < ssize(adj); i++) findBase(i);
+ assert(ssize(base) < 30);
int res = 0;
- for (int i = 1; i < (1 << sz(base)); i++) {
+ for (int i = 1; i < (1 << ssize(base)); i++) {
cycle cur;
- for (int j = 0; j < sz(base); j++)
+ for (int j = 0; j < ssize(base); j++)
if (((i >> j) & 1) != 0) cur ^= base[j];
if (isCycle(cur)) res++;
}