poj  1568:Find the Winning Move   [迭代博弈+搜索+剪枝] 题面省略... Input The input contains one or more test cases, followed by a line beginning with a dollar sign that signals the end of the file. Each test case begins with a line containing a question mark and…
Find the Winning Move 链接 题意: 4*4的棋盘,给出一个初始局面,问先手有没有必胜策略? 有的话输出第一步下在哪里,如果有多个,按(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1) ... 的顺序输出第一个.没有输出“#####”. 分析: 极大极小搜索 或者 对抗搜索,α+β剪枝. 极大极小搜索:每个人都会进行最聪明的决策,假设有1号玩家为我们希望的玩家(即判断他能否有必胜的走法),那么对于一号玩家进行决策时,让他去所有后继状态…
题目链接:http://poj.org/problem?id=1568 题意:给出一个4*4的棋盘,x和o两人轮流放.先放够连续四个的赢.给定一个局面,下一个轮到x放.问x是否有必胜策略?若有,输出能够赢的最小的坐标? 思路:(1)Maxfind(Min):每次放x,若得到的Max大于等于Min,则直接返回Max.因为Minfind要用这个Max更新Min,若x放置之后能够得到一个比Min大的,显然这样放最好:因为Min无法用Max更新: (2)Minfind(Max)类似: (3)因此,枚举第…
思路:用极大极小搜索解决这样的问题很方便!! 代码如下: #include <cstdio> #include <algorithm> #define inf 100000000 using namespace std; ][]; int x,y,num; bool ok(int x,int y) //判断是否胜 { int i; ;i<;i++) //(x,y)所在的行 if(str[x][i]!=str[x][y]) break; ) ; ;i<;i++) //(x…
搜索+剪枝--POJ 1011 Sticks 博客分类: 算法 非常经典的搜索题目,第一次做还是暑假集训的时候,前天又把它翻了出来 本来是想找点手感的,不想在原先思路的基础上,竟把它做出来了而且还是0ms过得.仔细想想,对搜索又有了一点点认识.     题目要求将一系列的sticks重新组合,形成若干相等相等长度的木棒,且尽量使木棒长度最小,如果数据量比较小的话,就纯粹是搜索了,但题目要求的 sticks可能达到64根,如果纯粹的搜索则显然是会远远超过1000ms的,因而也就把剪枝放在了很重要的…
Description An addition chain for n is an integer sequence  with the following four properties: a0 = 1 am = n a0<a1<a2<...<am-1<am For each k ( ) there exist two (not neccessarily different) integers i and j ( ) with ak =ai +aj You are give…
传送门 迭代加深搜索是必须的,先枚举加数个数 然后搜索分母 这里有一个强大的剪枝,就是确定分母的范围 #include <cstdio> #include <cstring> #define N 100001 #define LL long long #define min(x, y) ((x) < (y) ? (x) : (y)) #define max(x, y) ((x) > (y) ? (x) : (y)) int n, flag, best = 9999999…
Sticks Problem's Link:   http://poj.org/problem?id=1011 Mean: http://poj.org/problem?id=1011&lang=zh-CN&change=true analyse: 爆搜,但是其中蕴含着很多剪枝. Time complexity: O(n^2) Source code:  // Memory Time // 1347K 0MS // by : Snarl_jsb // 2014-11-07-17.14 #i…
POJ 1416 Shredding Company Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5231   Accepted: 2964 Description You have just been put in charge of developing a new shredder for the Shredding Company Although a "normal" shredder would…
POJ 1129 Channel Allocation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14191   Accepted: 7229 Description When a radio station is broadcasting over a very large area, repeaters are used to retransmit the signal so that every receive…