The positive solution should be DLX. Unfortunately, some of them used DFS + pruning, and some others used Random Algorithms. Various orz ....
I used the DFS + pruning of a big bull and optimized it in binary format ,,,,
Code:
/* State compression + iterative deepening search * // * Minimum master set * // * AC code: 7437 Ms */# include <iostream> # include <cstdio> # include <memory. h> # include <algorithm> # define LL (A) (a <1) # define RR (A) (a <1 | 1) # define one (_ int64 (1) # define goal (_ int64) (one <(2 * n)-1) // target State: Using namespace STD; int N, Cas, Pn, M, K, depth ;__ int64 st [100] ;__ int64 rest [100] ;__ int64 state; void Init () {int I, J, K, U, V, ith; scanf ("% d", & N); State = 0; Pn = n <1; for (I = 0; I <PN; I ++) {st [I] = r Est [I] = 0; // indicates that if one of them is in another State, the St [I] cannot be processed | = (one <I ); st [I] | = (one <(I ^ 1) ;}for (I = 0; I <n; I ++) {scanf ("% d ", & M); If (M = 1) state | = (one <RR (I); // indicates that the for (j = 0; j <m; j ++) {u = (LL (I) | j; scanf ("% d", & K); {for (k = 0; k <K; k ++) {scanf ("% d", & V, & ith); V = (LL (V) | ith; st [u] | = (one <v) ;}}// pre-processing rest [pn-1] = sT [pn-1]; for (I = pn-2; i> = 0; I --) Rest [I] = sT [I] | rest [I + 1];} bool DFS (_ int64 state, int D, int P) {int I; If (D = depth) return state = goal; For (I = P; I <n; I ++) {If (state | rest [LL (I)])! = Goal) break; // pruning // If (state | st [LL (I)]) = State) continue; if (DFS (state | st [LL (I)], D + 1, I + 1) return true; If (state | rest [RR (I)])! = Goal) break; If (state | st [RR (I)]) = State) continue; If (DFS (state | st [RR (I)], d + 1, I + 1) return true;} return false;} void solve () {depth = 1; // printf ("@ % i64d \ n ", goal); While (depth <n) // iterations deepen {If (DFS (State,) break; depth ++;} printf ("case % d: % d \ n ", CAS ++, depth) ;}int main () {int t; CAS = 1; scanf (" % d ", & T ); while (t --) {Init (); solve ();} return 0 ;}