摘要:
Description Input Output Sample Input Sample Output 阅读全文
摘要:
解题思路: 1.简单分析我们可以发现,当n=9时,最多只需要剪切八次即可完成排序。并且全排列数量9!=362880不算很大,所以我们可以将当前排列作为状态,转化成十进制数存入set以便判重。然后逐渐增加解答树的深度(搜索最大深度)进行迭代加深搜索。 2.构造启发函数。本题可以定义一个后继错数:当前状 阅读全文
摘要:
预备知识: 1.求0—n个数全排列的算法: 2.另一种求数组A全排列的方法是使用头文件<algorithm>中的next_permutation()函数,使用之前要排序。 用法如下: 下面进入正题: Description Input Output Sample Input Sample Outpu 阅读全文
摘要:
Description Input Output Sample Input Sample Output 1. 标准库默认使用元素类型的<操作符来确定它们之间的优先级关系。 通过<操作符可知在整数中元素大的优先级高。 2. 数据越小,优先级越高 greater<int> 定义在头文件 <funct 阅读全文
摘要:
Description Input Output Sample Input Sample Output 阅读全文
摘要:
解题思路: 1.注意到2*2方格中必有一个#,那么最多只有192条通道,可以将所有非‘#’的位置提取出来用邻接表的方式建图,通过bfs搜索目标位置。 2.将三个ghost的位置(a,b,c)作为状态量存储,如果采用邻接矩阵方式存储图,那么转移代价为5*5*5,很容易超时。分析题意可以知道图中结点大部 阅读全文
摘要:
10603 Fill There are three jugs with a volume of a, b and c liters. (a, b, and c are positive integers not greater than 200). The rst and the second j 阅读全文
摘要:
**1354 Mobile Computing** There is a mysterious planet called Yaen, whose space is 2-dimensional. There are many beautiful stones on the planet, and t 阅读全文