99// Complexity: O(nm + nm rank(M) / 64)
1010// Verified: abc276_h (2000 x 8000)
1111template <int Wmax>
12- std::vector<std::bitset<Wmax>> gauss_jordan (int W, std::vector<std::bitset<Wmax>> M) {
12+ std::vector<std::bitset<Wmax>> f2_gauss_jordan (int W, std::vector<std::bitset<Wmax>> M) {
1313 assert (W <= Wmax);
1414 int H = M.size (), c = 0 ;
1515 for (int h = 0 ; h < H and c < W; ++h, ++c) {
@@ -33,7 +33,7 @@ std::vector<std::bitset<Wmax>> gauss_jordan(int W, std::vector<std::bitset<Wmax>
3333}
3434
3535// Rank of Gauss-Jordan eliminated matrix
36- template <int Wmax> int rank_gauss_jordan (int W, const std::vector<std::bitset<Wmax>> &M) {
36+ template <int Wmax> int f2_rank_gauss_jordan (int W, const std::vector<std::bitset<Wmax>> &M) {
3737 assert (W <= Wmax);
3838 for (int h = (int )M.size () - 1 ; h >= 0 ; h--) {
3939 int j = 0 ;
@@ -72,25 +72,25 @@ template <int Wmax> int f2_determinant(const std::vector<std::bitset<Wmax>> &M)
7272
7373template <int W1, int W2>
7474std::vector<std::bitset<W2>>
75- matmul (const std::vector<std::bitset<W1>> &A, const std::vector<std::bitset<W2>> &B) {
75+ f2_matmul (const std::vector<std::bitset<W1>> &A, const std::vector<std::bitset<W2>> &B) {
7676 int H = A.size (), K = B.size ();
7777 std::vector<std::bitset<W2>> C (H);
7878 for (int i = 0 ; i < H; i++) {
7979 for (int j = 0 ; j < K; j++) {
80- if (A[i][j]) C[i] ^= B[j] ;
80+ if (A. at (i). test (j)) C. at (i) ^= B. at (j) ;
8181 }
8282 }
8383 return C;
8484}
8585
8686template <int Wmax>
87- std::vector<std::bitset<Wmax>> matpower (std::vector<std::bitset<Wmax>> X, long long n) {
87+ std::vector<std::bitset<Wmax>> f2_matpower (std::vector<std::bitset<Wmax>> X, long long n) {
8888 int D = X.size ();
8989 std::vector<std::bitset<Wmax>> ret (D);
9090 for (int i = 0 ; i < D; i++) ret[i][i] = 1 ;
9191 while (n) {
92- if (n & 1 ) ret = matmul <Wmax, Wmax>(ret, X);
93- X = matmul <Wmax, Wmax>(X, X), n >>= 1 ;
92+ if (n & 1 ) ret = f2_matmul <Wmax, Wmax>(ret, X);
93+ X = f2_matmul <Wmax, Wmax>(X, X), n >>= 1 ;
9494 }
9595 return ret;
9696}
@@ -101,7 +101,7 @@ std::vector<std::bitset<Wmax>> matpower(std::vector<std::bitset<Wmax>> X, long l
101101// Complexity: O(HW + HW rank(A) / 64 + W^2 len(freedoms))
102102template <int Wmax, class Vec >
103103std::tuple<bool , std::bitset<Wmax>, std::vector<std::bitset<Wmax>>>
104- system_of_linear_equations (std::vector<std::bitset<Wmax>> A, Vec b, int W) {
104+ f2_system_of_linear_equations (std::vector<std::bitset<Wmax>> A, Vec b, int W) {
105105 int H = A.size ();
106106 assert (W <= Wmax);
107107 assert (A.size () == b.size ());
@@ -111,7 +111,7 @@ system_of_linear_equations(std::vector<std::bitset<Wmax>> A, Vec b, int W) {
111111 for (int j = 0 ; j < W; ++j) M[i][j] = A[i][j];
112112 M[i][W] = b[i];
113113 }
114- M = gauss_jordan <Wmax + 1 >(W + 1 , M);
114+ M = f2_gauss_jordan <Wmax + 1 >(W + 1 , M);
115115 std::vector<int > ss (W, -1 );
116116 std::vector<int > ss_nonneg_js;
117117 for (int i = 0 ; i < H; i++) {
0 commit comments