summaryrefslogtreecommitdiff
path: root/content/graph
diff options
context:
space:
mode:
Diffstat (limited to 'content/graph')
-rw-r--r--content/graph/matching.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/content/graph/matching.cpp b/content/graph/matching.cpp
index 3619d7c..f0f34a3 100644
--- a/content/graph/matching.cpp
+++ b/content/graph/matching.cpp
@@ -1,22 +1,17 @@
-constexpr int MOD=1'000'000'007, I=10;
-vector<vector<ll>> adj, mat;
+constexpr int mod = 1'000'000'007, I = 10;
-int max_matching() {
+int max_matching(const vector<vector<int>> &adj) {
int ans = 0;
- mat.assign(ssize(adj), {});
+ vector<vector<ll>> mat(ssize(adj));
for (int _ = 0; _ < I; _++) {
for (int v = 0; v < ssize(adj); v++) {
mat[v].assign(ssize(adj), 0);
for (int u : adj[v]) {
if (u < v) {
- mat[v][u] = rand() % (MOD - 1) + 1;
- mat[u][v] = MOD - mat[v][u];
+ mat[v][u] = rand() % (mod - 1) + 1;
+ mat[u][v] = mod - mat[v][u];
}}}
- gauss(ssize(adj), MOD); //LGS @\sourceref{math/lgsFp.cpp}@
- int rank = 0;
- for (auto& row : mat) {
- if (*ranges::max_element(row) != 0) rank++;
- }
+ int rank = ssize(gauss(mat)); // LGS @\sourceref{math/lgsFp.cpp}@
ans = max(ans, rank / 2);
}
return ans;