POJ 1414 Life Line(搜索)】的更多相关文章

题意: 给定一块正三角形棋盘,然后给定一些棋子和空位,棋子序号为a(1<=a<=9),group的定义是相邻序号一样的棋子. 然后到C(1<=N<=9)棋手在空位放上自己序号C的棋子, 放完后, 不与空位相邻的group被消去, 每消去一个不是C的棋子得一分, 消去C的棋子扣一分, 问能得到最多的分数是多少. 分析: 令ans = 0: 搜索每一个棋子, 找出他的group. 如果这个group不与空位相邻, 而且棋子与棋手序号相等, 那么ans -= group数量, 如果棋子不…
POJ.3279 Fliptile (搜索+二进制枚举+开关问题) 题意分析 题意大概就是给出一个map,由01组成,每次可以选取按其中某一个位置,按此位置之后,此位置及其直接相连(上下左右)的位置(如果有)的0变成1,1变成0.现在求需要按多少次,才能使得整个map全部变成0. 此题解法与 UVA.11464 Even Parity 有异曲同工之妙. 首先可以看出,最多每个位置按一次,因为再按的话,相当于没按.如果我们枚举每一个位置是否按的话,2^(n*n)的复杂度爆炸. 接着思考,其实相对来…
Fliptile Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 16558   Accepted: 6056 Description Farmer John knows that an intellectually satisfied cow is a happy cow who will give more milk. He has arranged a brainy activity for cows in whic…
题目地址: http://poj.org/problem?id=1475 两重BFS就行了,第一重是搜索箱子,第二重搜索人能不能到达推箱子的地方. AC代码: #include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <string> #include <vector> #inc…
"Good man never makes girls wait or breaks an appointment!" said the mandarin duck father. Softly touching his little ducks' head, he told them a story. "Prince Remmarguts lives in his kingdom UDF – United Delta of Freedom. One day their ne…
The Triangle Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 37931   Accepted: 22779 Description 73 88 1 02 7 4 44 5 2 6 5 (Figure 1) Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on…
Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 26926   Accepted: 11174   Special Judge Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains…
Language: Default Test for Job Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 9733   Accepted: 2245 Description Mr.Dog was fired by his company. In order to support his family, he must find a new job as soon as possible. Nowadays, It's…
写到一半才发现能够用双向搜索4层来写,但已经不愿意改了,干脆暴搜+剪枝水过去算了. 想到一个非常水的剪枝,h函数为  当前点到终点4个点的最短距离加起来除以2.由于最多一步走2格,然后在HDU上T了,又发现再搜索过程中.这个估价函数应该是递减的(贪心),再加上这个剪枝就过了. #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<list>…
题目地址: http://poj.org/problem?id=1324 优先队列---A*的估价函数不能为蛇头到(1,1)的距离,这样会出错. 看了discuss,有大神说这题A*的估价函数为BFS (0,0)到各点的花费在乘上10 ,但是还是不清楚,希望知道的可以给我留个言,谢谢了. 思路: 用0,1,2,3表示方向,这样就可以用四进制状态压缩了. 总共需要3+3*4^1+……3*4^6. 推荐大家能不用STL就不用STL,太浪费时间了. 下面是用STL超时代码和用数组模拟AC代码. 超时代…