Code Library Of Others/sgtlaugh/Algorithm X + Dancing Links.cpp
inline void addrow(int r, vector <int>& columns){ /// hash = 438353
        int i, c, l = columns.size(), first = idx;

        for (i = 0; i < l; i++){
            c = columns[i];
            L[idx] = idx - 1, R[idx] = idx + 1, D[idx] = c, U[idx] = U[c];
            D[U[c]] = idx, U[c] = idx, row[idx] = r, col[idx] = c;
            column_count[c]++, idx++; /// column_count[c] is the number of rows which satisfies constraint column c
        }
        R[idx - 1] = first, L[first] = idx - 1;
    }
/// r = index of row (1 based)
/// the vector columns contain the columns which are satisfied with this row
r = index of row (1 based)
the vector columns contain the columns which are satisfied with this row
r = index of row ( 1 based ) the vector columns contain the columns which are satisfied with this row
inline void addrow(int r, vector <int>& columns){ 
        int i, c, l = columns.size(), first = idx;
        for (i = 0; i < l; i++){
            c = columns[i];
            L[idx] = idx - 1, R[idx] = idx + 1, D[idx] = c, U[idx] = U[c];
            D[U[c]] = idx, U[c] = idx, row[idx] = r, col[idx] = c;
            column_count[c]++, idx++; 
        }
        R[idx - 1] = first, L[first] = idx - 1;
    }
inline void addrow ( int r , vector < int > & columns ) { int i , c , l = columns . size ( ) , first = idx ; for ( i = 0 ; i < l ; i ++ ) { c = columns [ i ] ; L [ idx ] = idx - 1 , R [ idx ] = idx + 1 , D [ idx ] = c , U [ idx ] = U [ c ] ; D [ U [ c ] ] = idx , U [ c ] = idx , row [ idx ] = r , col [ idx ] = c ; column_count [ c ] ++ , idx ++ ; } R [ idx - 1 ] = first , L [ first ] = idx - 1 ; }
r = index of row (1 based)
the vector columns contain the columns which are satisfied with this row
r = index of row ( 1 based ) the vector columns contain the columns which are satisfied with this row
/// hash = 438353 /// column_count[c] is the number of rows which satisfies constraint column c