BZOJ_3049_[Usaco2013 Jan]Island Travels _状压DP+BFS Description Farmer John has taken the cows to a vacation out on the ocean! The cows are living on N (1 <= N <= 15) islands, which are located on an R x C grid (1 <= R, C <= 50). An island is a…
这是今天下午的互测题,只得了60多分 分析一下错因: $dis[i][j]$只记录了相邻的两个岛屿之间的距离,我一开始以为可以,后来$charge$提醒我有可能会出现来回走的情况,而状压转移就一次,无法实现来回走的情况,所以加了一个类似$floyed算法$的三重循环来更新每个点的距离,然后状态转移就可以了,枚举起点和终点,最后统计答案 #include<cstdio> #include<cstring> #include<algorithm> using namespa…
题目链接 The input contains mutiple testcases. Please process till EOF.For each testcase, the first line contains two integers N (1 ≤ N ≤ 15), the side length of the square map and M (1 ≤ M ≤ 15), the number of tunnels.The map of the city is given in the…
Problem Description Bob is travelling in Xi’an. He finds many secret tunnels beneath the city. In his eyes, the city is a grid. He can’t enter a grid with a barrier. In one minute, he can move into an adjacent grid with no barrier. Bob is full of cur…
孤岛营救问题 https://www.luogu.org/problemnew/show/P4011 用状压DP标记拿到钥匙的数量 #include<iostream> #include<cstring> #include<string> #include<algorithm> #include<cmath> #include<queue> #include<vector> #include<cstdio> u…
来自xjy的签到题   Description 爱丽丝冒险来到了红皇后一个n*n大小的花园,每个格子由'.'或'#'表示,'.'表示爱丽丝可以到达这个格子,‘#’表示爱丽丝不能到达这个格子,爱丽丝每1分钟可以移动到非'#'的相邻格子(与当前所在格子具有公共边).花园下面有m个隧道,每个隧道有一个出口和一个入口.当爱丽丝到达隧道的入口时,她可以选择(也可以不选择)进入隧道入口,并通过隧道一次,然后立即(不花费时间)出现在隧道出口.爱丽丝一开始可以降临在花园的任何地方.有好奇心的爱丽丝想知道,她通过…
Problem Description Rompire is a robot kingdom and a lot of robots live there peacefully. But one day, the king of Rompire was captured by human beings. His thinking circuit was changed by human and thus became a tyrant. All those who are against him…
Description  Input 本题包含多组数据. 第一行:一个整数T,表示数据的个数. 对于每组数据: 第一行:两个整数,N和K(含义如题目表述). 接下来N行:每行一个字符串. Output 1 2 1 a? ?b Sample Input 50 Sample Output 对于30%的数据,T ≤ 5,M ≤ 5,字符串长度≤ 20: 对于70%的数据,T ≤ 5,M ≤ 13,字符串长度≤ 30: 对于100%的数据,T ≤ 5,M ≤ 15,字符串长度≤ 50. [思路] 状压D…
Description 小F 的学校在城市的一个偏僻角落,所有学生都只好在学校吃饭.学校有一个食堂,虽然简陋,但食堂大厨总能做出让同学们满意的菜肴.当然,不同的人口味也不一定相同,但每个人的口味都可以用一个非负整数表示.由于人手不够,食堂每次只能为一个人做菜.做每道菜所需的时间是和前一道菜有关的,若前一道菜的对应的口味是a,这一道为b,则做这道菜所需的时间为(a or b)-(a and b),而做第一道菜是不需要计算时间的.其中,or 和and 表示整数逐位或运算及逐位与运算,C语言中对应的运…
题解: 看到区间修改先想一下差分 这题用差分是为了分析问题 现在的问题就变成了 原序列全为0,要使得特定的k个点变为1,每个操作改变x,y+1 然后我们会发现 对于二元组a,b我们要修改它,实际上是在找连续的区间相连,所以实质上是最短路 为什么要差分了才能这么做呢 因为原来的区间修改可能中间涉及了有效点而变得复杂 现在每次有效操作不会影响到中间的有效点 接下来状压dp这是显然的 对于每一个状态,枚举二元组(确定其中一个值,枚举另一个值) 这是因为被确定的这个值一定是其中一个二元组 在做这个之前,…