Skip to content

Commit

Permalink
Shorten some lines that where to long
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanRenison committed Mar 6, 2024
1 parent c52bac7 commit ed4f762
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion content/graph/EdmondsKarp.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
*/
#pragma once

template<class T> T edmondsKarp(vector<unordered_map<int, T>>& graph, int source, int sink) {
template<class T> T edmondsKarp(vector<unordered_map<int, T>>&
graph, int source, int sink) {
assert(source != sink);
T flow = 0;
vi par(sz(graph)), q = par;
Expand Down
5 changes: 3 additions & 2 deletions content/numerical/MatrixInverse-mod.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ int matInv(vector<vector<ll>>& A) {
return i;
found:
A[i].swap(A[r]); tmp[i].swap(tmp[r]);
rep(j,0,n) swap(A[j][i], A[j][c]), swap(tmp[j][i], tmp[j][c]);
rep(j,0,n)
swap(A[j][i], A[j][c]), swap(tmp[j][i], tmp[j][c]);
swap(col[i], col[c]);
ll v = modpow(A[i][i], mod - 2);
rep(j,i+1,n) {
Expand All @@ -46,6 +47,6 @@ int matInv(vector<vector<ll>>& A) {
}

rep(i,0,n) rep(j,0,n)
A[col[i]][col[j]] = tmp[i][j] % mod + (tmp[i][j] < 0 ? mod : 0);
A[col[i]][col[j]] = tmp[i][j] % mod + (tmp[i][j] < 0)*mod;
return n;
}
6 changes: 4 additions & 2 deletions content/numerical/NumberTheoreticTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ void ntt(vl &a) {
}
vl conv(const vl &a, const vl &b) {
if (a.empty() || b.empty()) return {};
int s = sz(a) + sz(b) - 1, B = 32 - __builtin_clz(s), n = 1 << B;
int s = sz(a) + sz(b) - 1, B = 32 - __builtin_clz(s),
n = 1 << B;
int inv = modpow(n, mod - 2);
vl L(a), R(b), out(n);
L.resize(n), R.resize(n);
ntt(L), ntt(R);
rep(i,0,n) out[-i & (n - 1)] = (ll)L[i] * R[i] % mod * inv % mod;
rep(i,0,n)
out[-i & (n - 1)] = (ll)L[i] * R[i] % mod * inv % mod;
ntt(out);
return {out.begin(), out.begin() + s};
}

0 comments on commit ed4f762

Please sign in to comment.