Reprint Please specify the source Thank you: http://blog.csdn.net/vmurder/article/details/42886393ExercisesWell, this picture is really not very good to do,But we can convert it to perfection is a 1/0 sub-matrix problem.is to reverse the point 01 of the same row parity, and then it's OK (this is obviously, need to prove the message).And then we're asking for the maximum sub-matrix.As for the square? To seek the sub-matrix by the way, that is the ans1,This is obviously because we enumerate the du
Topic: Given a black and white matrix, the largest black and white sub-squares and sub-matricesReverse the point of an odd position, then the largest sub-square and sub-matrix of the solid colorThe matrix is divided into layers, above each layer is a similar to the ▆▃▇▂▉, with a monotonous stack run out each point left to right can expand to the maximum distance, update the answer can be#include Bzoj 1057 ZJOI2007 checkerboard making monotone stack
Title: Give a matrix formed by 01, ask the matrix of the largest area of the square and the rectangle, any one of the squares adjacent to a different lattice.Idea: In fact, all (i + j) 1 in the position of the number XOR, it becomes all 0 or 1 of the largest squares and rectangles. The first question is water DP, the second question can be monotonic stack or hanging line. are very well written.CODE:#include Bzoj 1057 Zjoi 2007 checkerboard Production
Chinese problem, title no longer explained, simple DFS;#include #include #include #include #include BOOL Maps[10][10];//maps make a chessboard, judge this point can play chess maps[0][i] used to record column I can play chessint N, k, ans, Hang;//hang represents the moment in the first few lines of chessvoid DFS (int k){if (k = = 0) {//pieces are put outans++;Return}if (Hang > N)//The number of rows checked is greater than or equal to N, at which point K is not equal to 0;Returnif (N-hang + 1 Re
][j][k]+=dp[i-1][k][j-1]* (k) * (m-j-k+1)/2;5: Put a gun in a row with a gun and a gun in a row with a cannon, the equation is dp[i][k][j]+= (k+2) * (k+1)/2*dp[i-1][k+2][j-2];6: Put a gun in a row without a gun and put a gun in a row without a gun, the equation is dp[i][k][j]+= (m-j-k+2) * (m-j-k+1)/2*dp[i-1][k-2][j];Okay, now we can put the code on. #include #include#defineMoD 999983using namespacestd;intn,m;Long Long intdp[101][101][101],ans=0;intMain () {scanf ("%d%d",n,m); dp[0][0][0]=1; f
Title Description
Given a 4*4 01 chessboard, 1 represents a pawn, 0 represents a space, and a pawn 1 can be moved to a space next to or below four positions in each of the adjacent places. Then given your target chessboard, ask you at least how many steps you can take to turn the current chessboard into a target checkerboard state. input
The first line enters an integer t, which indicates that there is a T group of test data. Next, we give a 4*4 of o
topic AC.Idea: Store the Board area position in an array, and then each checkerboard area either places a piece, or does not put a pawn, deep search (equivalent to generate the number of permutations).For a chessboard area can play chess pieces, like the eight queens, we use two Boolean array to maintain, r[i] to indicate whether there is a pawn in line I, C[j] Indicates whether there is a pawn in column J.The deep search function maintains two param
DescriptionIn a given shape of the chessboard (the shape may be irregular) on the top of the pieces, chess pieces no difference. If you need to place any of the two pieces in the same row or column in the chessboard, please program the chessboard with a given shape and size, and put all the feasible arrangement C for the K pieces.InputThe input contains multiple sets of test data.The first row of each set of data is two positive integers, n K, separated by a space, indicating that the chessboard
[i]) { - for(intj =1; J //look for "#" in the line to if(Map[i][j] = ='#' Row[j] = =0) { +Chose[i] = j;//The first t piece is placed in the J position of line I -ROW[J] =1; theChessdfs (t +1); *ROW[J] =0; $ }Panax Notoginseng } - } the } + } A } the + intCheckintk) { - for(inti =1; I ) { $ if(Map[k][i] = ='#' Chose[k])return 1; $ } - return 0; - } the - voidLinedfs (intt) {Wuyi
answer is to see the board on the odd number of or even a number of black pieces;AC Code:#include /*#include */using namespacestd;#defineRiep (n) for (int i=1;i#defineRIOP (n) for (int i=0;i#defineRJEP (n) for (int j=1;j#defineRJOP (n) for (int j=0;j#defineMST (SS,B) memset (ss,b,sizeof (ss));typedefLong LongLL;ConstLL mod=1e9+7;Const DoublePi=acos (-1.0);ConstLL inf=1e18;Const intn=1e5+4;intn,m,a[ the][ the];intMain () {intT; scanf ("%d",t); while(t--) {scanf ("%d%d",n,m); intsum=0; Riep (n)
DescriptionIn a given shape of the chessboard (the shape may be irregular) on the top of the pieces, chess pieces no difference. If you need to place any of the two pieces in the same row or column in the chessboard, please program the chessboard with a given shape and size, and put all the feasible arrangement C for the K pieces.InputThe input contains multiple sets of test data.The first row of each set of data is two positive integers, n K, separated by a space, indicating that the chessboard
Title: Give an n * N chess board, there are some places on this board can not play chess pieces.Now ask you to put a K on this board, so that any of these pieces of two not on the same row, ask how many waysProblem-solving ideas: Similar to the N-queen, can be a line of processing, with the binary 1 means that the position can be put, 0 means no, all indicates the status of each row can be put ((1 Assuming the state of the column is S, then S (the line's limit) All is the end state of the row.
http://poj.org/problem?id=1321Because the search is originally written, and the training time did not come so can only now fill the-_-A simple deep search#include #includestring.h>#include#include#defineN 10#defineINF 0XFFFFFFF#include#includeusing namespacestd;intN,ans,k,num,vis[n],sx,sy;CharMaps[n][n];voidDfsintM//M is the first few lines;{ inti; if(num==k) {ans++; return ; } if(m>=N)return ; for(i=0; i) { if(vis[i]==0maps[m][i]=='#') {num++; Vis[i]=1; DFS (M+1); Vis[i]=0; Num
Reprint please indicate the source CSDN ametake All rights reservedTitle Description DescriptionThe number triangle must pass a certain point to make it go the distance and the maximumEnter a description input DescriptionRow 1th N, representing n rows2nd to n+1 behavior each weight valueThe program must go through the N Div 2,n Div 2 pointOutputs description output DescriptionMaximum ValueSample input to sample211 1Sample output sample outputs2Data size HintN Listen to Lu Jinglong god Ben tod
An n * N chess board, some lattices can not put, put the pieces of M,each of the two pieces cannot be in the same row or column, ask how many kinds of release methodDfs is too slow, use SCR better dotPython has only 22 lines, which in fact can be shorter. But it's going to be a very long, very long line.While true:table = [[0 to J in Range] ' for I in range ()] table[0][0] = 1 boardsize, chessnum = ma P (int, raw_input (). Split ()) if boardsize = = Chessnum = -1:break states = Range (1 Dynamic
into nine regions and then discuss the relationship between the four corners of the modified matrix four edges and the entire position and the nine regionsThe red area in the figure shows +, and the green area indicates-For a chestnut, if the upper-left corner of a matrix is in the first quadrant, it will subtract the modified value from the point (x1-1,y1)If a matrix crosses the vertical axis and the lower boundary is below the origin, it will subtract the modified value from the point (x,y2+1
square as a special point (first divided into 4 smallSquare, find the square with no special points, and the other 3 is the middle point of the large square as a special point),3 special points are connected to a top L domino, so that each small square has a special point, when 2x2, no matterWhere the special points can be combined with L dominoes a square, then for 1x1, end;#include intts[ -][ -];inttile=1;voidChesint,int,int,int,int);voidChesintH1,intL1,intXintYintsize) { intt,s; if(size==
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.