Topic Link http://poj.org/problem?id=1191problem: 1191User: yinjianMemory: 568K time: 16MSLanguage: C + + Result: AcceptedProblem Solving Report:1, the formula can be used to simplify the mathematical method, is to find the number (sum) of the sum of the squares and the smallest.2, each division has four kinds of cases (recursion).3, each time the location of the division to be compared, so as to find the best.#include #include#include#includestring.h>using namespacestd;ints[9][9];//the score o
The main topic: there is a 5*n (≤100) board, some of the checkerboard has been dyed black, for the minimum number of lattice staining, all the black can be connected together.This problem card I 1h, wrote 2.6k code, Qingming homework a lump has not done ah ... Before always thought that this is the plug DP, the results of today's look found not >_Because there are only 5 columns, so there are at most 3 black Unicom blocks per line, that is, black, whi
C-Checkerboard IssuesTime limit:MS Memory Limit:10000KB 64bit IO Format:%i64d %i64u SubmitStatusPracticePOJ 1321DescriptionIn 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 i
Checkerboard Issues
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 26726
Accepted: 13242
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 th
Title Link: Checkerboard IssuesParsing: DFS violence searches from top to bottom, from left to right.AC Code:Code 1#include Code 2#include Copyright NOTICE: This article is sxk original article, reprint please attach this article link ^_^ POJ 1321 Checkerboard Problem (DFS)
Title Link: POJ 1321 checkerboard Problem
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 28825
Accepted: 14276
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 an
Checkerboard Issues
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 24958
Accepted: 12333
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 th
2017-08-26 20:18:50Writer:pprpThe question probably describes:Have a 2k? 2k checkers, just one square is black, the other is white. Your task is to cover all white squares with an L-shaped card containing 3 squares.Black squares cannot be overwritten, and any white squares cannot be overwritten by two or more cards at the same time.Divide and conquer the solution, when the division of the time to determine the state, need what state, the end of conditionsThe end condition is that when siz
In 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.-------------------------------------------------------------------#include#include#include#include#includeint MN;Char Str[105][105];int dir[8][2]={{1,1},{-1,1},{-1,-1},{1,-1}};in
number of pieces to be placed. N When 1-1 indicates the end of the input.The following n-line description describes the shape of the chessboard: N characters per line, where # indicates the board area. Represents an empty area (the data guarantees that no extra blank lines or blank columns appear).OutputFor each set of data, give a line of output, the output is placed in the number of programs C (Data Assurance cSample Input2 #.. #4 4...#. #.. #.. #...-1-1Sample Output21stThe code is as follows
top and left of the minimum value. But in the beginning did not take into account the status of the situation is covered, only opened an array WA for a long time. Open two arrays one in the initial state after a storage and transfer state can be. rib[i][j]=min (rib[i-1][j],rib[i][j-1]) +board[i][j]. AC Code: 1#include 2#include 3 using namespacestd;4 Const intINF =2147483647 ;5 intN;6 intboard[ the][ the],rib[ the][ the] ;7 intMain () {8scanf"%d",N);9 for(intI=1; ii)Ten for(intj
(Maxval, Dp[x1][y1][x2][y2]); the } About } the } theDP[I][J][K][L] = max (Dp[i][j][k][l], Maxval + arr[i][j] +arr[k][l]); the } + } - } the //two path to reach Point [M][n], then the point of the two path must choose: [M][n-1],[m-1][n]Bayi intans = max (Dp[m][n-1][m-1][n], Dp[m-1][n][m][n-1]); the //for (int i = 1; I the //{ - //For (int j = 1; j - // { the //for (int k = 1; k
] +arr[i][j]);Wuyi } the if(Check (x2, y2, I-1)) - { WuDP[I][J] = max (Dp[i][j], Dp[x2][y2] +arr[i][j]); - } About } $ } - /*for (int i = 1; I - { - For (int j = 1; J A { + cout the } - }*/ $cout 1) Endl; the } the the intMain () the { - #ifdef HOME inFreopen ("inch","R", stdin); the //freopen ("Out", "w", stdout); the #endif About for(inti =0; i i) the { the for(intj =0; J j) the
instead of some bfs thought of Dfs, but because there is no storage state like BFS, so do some repetitive work, time will be slower than the first method.) )3) WA, not yet debugged:Because it is important to realize that the key to solving the problem is that the sub-change and change two times in each position is actually the same. change the effect of paragraph A and then change the sub-B is equivalent to first change the sub-B and then change the sub-A is not related to the order, so I envi
pieces we need to place, and then ask us how to put them in several ways. First we can make it clear that this is a topic of deep search, similar to the eight Queens question. We create a function Dfs is used to accumulate the number of feasible scenarios, we walk through a column we will mark it down the next time we can not be placed in this column (because the title is not allowed to be placed in the same row and the same column)Then start looking for a viable place from the next line, until
(Visi,0,sizeof(Visi)); memset (VISJ,0,sizeof(VISJ)); memset (Vis1,0,sizeof(VIS1)); memset (Vis2,0,sizeof(VIS2)); if(Dfs (0,0,0)) Break; } printf ("Case %d:%d\n",++Cas,maxd); } return 0;}The first kind of pruning3. You can place rows (or columns) on a row-by-line basis. There is also a pruning is up to 5, so maxd==4 has no solution, direct output 5.0.201s#include #includeConst intMAXN = One;CharG[MAXN][MAXN];intMaxd;intn,m;BOOLvisi[maxn],visj[maxn],vis1[maxn1],vis2[maxn1];BOOLDfsintDintsi) {
So simple a topic, thought for so long, also WA once, unforgivable ah, more and more feel stupid, Dfs search will not write ... LuoConfusion, we must seriously think about the topic, seriously write code:Code:#include Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. POJ 1321 Checkerboard Problem Simple DFS
One, test instructions:Chinese questionsSecond, analysis:The main use of compressed DP and memory search ideasThree, code:#include Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. POJ 1191 Checkerboard Segmentation (compression dp+ memory Search)
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.