DFS: Connected blocksTitle: There is a garden of size n x m, which accumulates water after rain. Eight connected water is considered to be connected together. How many puddles are there in total in the garden?(eight-connected refers to the figure of the relative W of the * section), w means water, * indicates no waterFor example:W........ Ww.. WWW.....WWW....WW...WW..........WW..........W...W.......W...W.W.....WW.W.W.W.....W..W.W......W...W.......W.Output 3#include int N;int M;Char arr[102] [102
cases. The first line of all test case contains three integers n, m, and T (1 ' X ': a block of wall, which the doggie cannot enter;' S ': The start point of the doggie;' D ': the Door; Or'. ': an empty block.The input is terminated with three 0 ' s. This test is a not-to-be processed.Outputfor each test case, print on one line "YES" if the doggie can survive, or "NO" otherwise.Sample Input4 4 5S. X... X... Xd.... 3 4 5S. X... X.... D0 0 0Sample Outputnoyes/*0 1 0 1 0 11 0 1 0 1 00 1 0 1 0 11 0
positive integers a,b,c and T (1Special note: The test data is very large, please use scanf input, I can not guarantee that using CIN can not time out. On this OJ, submit using Visual C + +.OutputFor each set of test data, if Ignatius can leave the castle before the Devil returns, then output-1 if the minimum number of minutes is required.Sample Input13 3 4 200 1 1 10 0 1 10 1 1 11 1 1 11 0 0 10 1 1 10 0 0 00 1 1 00 1 1 0Sample Output11AuthorIgnatius.lRecommendIGNATIUS.L | We have carefully sel
My mom, this card has me for two days.In fact very simple, on each starting point down the BFS, control the continuous section of the arid zone. It is then converted to a DP problem that covers all areas with the fewest segments.However?!! I didn't know how to write a magical greed at first. The miserable world.#include #include #include #include #include using namespace Std;const int maxn=505;struct SEG{int left,right;}S[MAXN*3];int map[maxn][maxn],n,m;int DX[]={0,0,1,0,-1},DY[]={0,-1,0,1,0},CN
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.