HDUOJ---------(1045)Fire Net】的更多相关文章

题目传送门 /* 题意:在一个矩阵里放炮台,满足行列最多只有一个炮台,除非有墙(X)相隔,问最多能放多少个炮台 搜索(DFS):数据小,4 * 4可以用DFS,从(0,0)开始出发,往(n-1,n-1)左下角走,x = cnt / n; y = cnt % n; 更新坐标, 直到所有点走完为止,因为从左边走到右边,只要判断当前点左上方是否满足条件就可以了 注意:当前点不能放炮台的情况也要考虑 g[x][y] == 'o'; 的错误半天才检查出来:) */ #include <cstdio> #…
http://acm.hdu.edu.cn/showproblem.php?pid=1045 Fire Net Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1045 Description Suppose that we have a square city with straight streets. A map of a city…
HDOJ(HDU).1045 Fire Net [从零开始DFS(7)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双重DFS HDOJ.1010 Tempter of the Bone [从零开始DFS(1)] -DFS四向搜索/奇偶剪枝 HDOJ(HDU).1015 Safecracker [从零开始DFS(2)] -DFS四向搜索变种 HDOJ(HDU).1016 Prime Ring Problem (DFS) [从零开…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1045 Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 15715    Accepted Submission(s): 9519 Problem Description Suppose that we have a square…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1045 Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 14670    Accepted Submission(s): 8861 Problem Description Suppose that we have a squar…
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1045 Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8073    Accepted Submission(s): 4626 Problem Description Suppose that we have a squar…
以防万一,题目原文和链接均附在文末.那么先是题目分析: [一句话题意] 给定大小的棋盘中部分格子存在可以阻止互相攻击的墙,问棋盘中可以放置最多多少个可以横纵攻击炮塔. [题目分析] 这题本来在搜索专题里出现的..这回又在二分查找匹配专题出现了..所以当然要按照二分匹配的方法解而不是爆搜(虽然爆搜能过). 问题主要就是如何缩点建图.为了使得blockhouse不能互相攻击,那么使用每行的相邻的点缩点,每列的相邻的点缩点,连边的条件就是两个点存在有相交的部分,最后这两组点求最大匹配就行了. [算法流…
Fire Net Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1045 Description Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, e…
Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5863    Accepted Submission(s): 3280 Problem Description Suppose that we have a square city with straight streets. A map of a city is a s…
Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7922    Accepted Submission(s): 4514 Problem Description Suppose that we have a square city with straight streets. A map of a city is a s…
Fire Net Problem Description Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall. A blockhouse is a small castle that has four openings t…
Description Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall. A blockhouse is a small castle that has four openings through which to s…
Description Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall. A blockhouse is a small castle that has four openings through which to s…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1045 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description Suppose that we have a square city with straight streets. A map of a city is a square board…
Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 14780    Accepted Submission(s): 8932 Problem Description Suppose that we have a square city with straight streets. A map of a city is a…
http://acm.split.hdu.edu.cn/showproblem.php?pid=1045 http://acm.hdu.edu.cn/showproblem.php?pid=1045 题目链接(总有一个可以点开)…… 题意:给出一张地图,上面只有两种字符(.和X),X相当于无法穿透的墙.问这张地图上最多可以放置多少个互不攻击的子弹…… 第一反应是搜索,然而后来看到网上有些大神说这是二分图匹配……看来还是要研究下. 我剪枝的思路:对每个点设置所有关联的点(上下左右四个方向直到被墙挡…
HDU 1045 题意: 在一个n*n地图中,有许多可以挡住子弹的墙,问最多可以放几个炮台,使得炮台不会相互损害.炮台会向四面发射子弹. 思路: 把行列分开做,先处理行,把同一行中相互联通的点缩成一个点.再处理列,同样缩成一个点.然后把行列中,交点不是墙的点连一条边.对这个图跑网络流或者二分图匹配即可. #include <algorithm> #include <iterator> #include <iostream> #include <cstring>…
Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7998    Accepted Submission(s): 4573 Problem Description Suppose that we have a square city with straight streets. A map of a city is a s…
Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8239    Accepted Submission(s): 4734 Problem Description Suppose that we have a square city with straight streets. A map of a city is a s…
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1045 题目大意为给定一个最大为4*4的棋盘,棋盘可以放置堡垒,处在同一行或者同一列的堡垒可以相互攻击,在棋盘上也有城墙,可以隔离同一行同一列堡垒的相互攻击,"X"表示有城墙," . "表示空地,问该棋盘最多可以放置多少个堡垒? 此题为二分图匹配问题,但是起初我不知道怎么建图,看题解发现一个规律,同一行同一列的连续空地不能放置两个堡垒,那么同一行同一列的连续空地的交点放置…
题意:给你一个正方形棋盘.每个棋子可以直线攻击,除非隔着石头.现在要求所有棋子都不互相攻击,问最多可以放多少个棋子. 这个题可以用搜索来做.每个棋子考虑放与不放两种情况,然后再判断是否能互相攻击来剪枝.最后取可以放置的最大值. 这里我转化成求最大独立集来做. 首先将每个空地编号,对于每个空地,与该位置可以攻击到的空地连边.找最多的空地使得不互相攻击,即求该图的最大独立集.与搜索做法基本一致,但是说法略有不同. #include<iostream> #include<cstring>…
经典深搜.注意满足条件. #include <stdio.h> #include <string.h> #define MAXNUM 5 char map[MAXNUM][MAXNUM]; int visit[MAXNUM][MAXNUM]; int chk(int row, int col, int n) { int i, k; || row>=n || col< || col>=n ) ; if (visit[row][col] || map[row][col…
题目大意: 这个是以前做过的一道DFS题目,当时是完全暴力写的. 给你一个N代表是N*N的矩阵,矩阵内 ‘X’代表墙, ‘.’代表通道. 问这个矩阵内最多可以放几个碉堡, 碉堡不能在同一行或者同一列,除非他们中间有墙.   二分图做法思想:我们用行去匹配列,判断最大匹配数. 我们需要重新构图, 假如一行中 (  ..X..X.. ) 那么在这一行中我们其实是可以分割到三个不同的行(因为中间隔有X).然后对这个三个行进行编号.同理列也是一样的.当我们完全构好图后就可以做完全匹配了,其他的跟HDU…
<题目链接> 题目大意: 这题意思是给出一张图,图中'X'表示wall,'.'表示空地,可以放置炮台,同一条直线上只能有一个炮台,除非有'X'隔开,问在给出的图中最多能放置多少个炮台. 解题分析: 本题可用DFS求解 >>> ,但是二分匹配的想法更加巧妙,效率也更高.二分匹配的主要思想就是,对矩阵的行连通块和列连通块进行标号,然后根据矩阵的每个点,建立对应的行连通块和列连通块之间的待匹配关系,然后利用匈牙利进行正式匹配,这样当某个行联通块与某个列连通块正式确立匹配关系的时候,…
题目链接 Problem DescriptionSuppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall. A blockhouse is a small castle that has four openings throug…
题意:n*n的棋盘上放置房子.同一方同一列不能有两个,除非他们之间被墙隔开,这种话. 把原始图分别按行和列缩点 建图:横竖分区.先看每一列.同一列相连的空地同一时候看成一个点,显然这种区域不可以同一时候放两个点. 这些点作为二分图的X部.同理在对全部的 行用同样的方法缩点.作为Y部. #include<cstdio> #include<iostream> #include<algorithm> #include<cmath> #include<set&…
(点击此处查看原题) 匈牙利算法简介 个人认为这个算法是一种贪心+暴力的算法,对于二分图的两部X和Y,记x为X部一点,y为Y部一点,我们枚举X的每个点x,如果Y部存在匹配的点y并且y没有被其他的x匹配,那就直接匹配:如果Y中已经没有可以和x匹配的点(包括可以匹配的点已经被其他的x匹配),那就让已经匹配的y的原配x'寻找其他可以匹配的y’,并将y和x匹配,最后,统计出匹配的对数 (详细了解的话,可以看看这位的博客:https://blog.csdn.net/sunny_hun/article/de…
题意:任意两个个'车'不能出现在同一行或同一列,当然如果他们中间有墙的话那就没有什么事,问最多能放多少个'车' 代码+注释: 1 //二分图最大匹配问题 2 //难点在建图方面,如果这个图里面一道墙也没有,那么可以说就是在横坐标(1...n)和纵坐标(1...n) 3 //中个挑选出来一个,那个点就是我们要放置炮台的地方,么个点只能用一次,这样就能保证正确性 4 //现在现在里面有墙了,在横坐标方面那么看到一个墙就把横坐标的选择数加1,每次换行也加1 5 //纵坐标也做相应处理,那么我们就可以得…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1045 Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8185    Accepted Submission(s): 4691 Problem Description Suppose that we have a squa…
http://acm.hdu.edu.cn/showproblem.php?pid=1045 Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6756    Accepted Submission(s): 3829 Problem Description Suppose that we have a square ci…