First, understand the title meaning: Everyone can only work on the list of one job and two people can not do a job at the same time.
AC thinking: The use of violence to enumerate each possible allocation scheme, the resolution of sub-problems gradually upward solve the problem of the mother, the final solution.
Standard range Notdeep (cattle and Guest network)
Links: https://www.nowcoder.com/discuss/22696?type=6&order=0&pos=5&page=2
1#include <bits/stdc++.h>2 3 using namespacestd;4 5vector<string> A;//a Save work sequence list6 intN;7 intb[Ten];//flag Array B[i] is used to record whether work with number I has been assigned, 0 is assigned, 1 is not assigned8 intRet//record number of allocation plans9 Ten voidDfsinti) {//Dfs[i] means assigning work to people numbered I to a.size () 1 when the person with the number 0 to I-1 has been assigned a job . One if(i = =a.size ()) { Aret++;//end of an allocation scheme -}Else { - for(intj =0; J < A[i].size (); J + +) { the if(B[a[i][j]-'0']) { -B[A[I][J]-'0'] =0; -DFS (i +1); -B[A[I][J]-'0'] =1; + } - } + } A } at - intMain () { - - while(Cin >>N) { - for(inti =0; I < n; i++) { - stringX CIN >>x; in a.push_back (x); - } to for(inti =0; I <Ten; i++) B[i] =1; +RET =0; -Dfs0); thecout << ret <<Endl; * } $ return 0;Panax Notoginseng}
A day algorithm programming problem (1)--NetEase written "engineer's work arrangement"