搜索
文章平均质量分 59
ctsas
这个作者很懒,什么都没留下…
展开
-
【51nod】1118 机器人走方格 记忆优化宽度优先搜索
广度优先搜索算法(英语:Breadth-First-Search,缩写为BFS),又译作宽度优先搜索,或横向优先搜索,是一种图形搜索算法。简单的说,BFS是从根节点开始,沿着树的宽度遍历树的节点。如果所有节点均被访问,则算法中止。广度优先搜索的实现一般采用open-closed表。 BFS是一种盲目搜寻法,目的是系统地展开并检查图中的所有节点,以找寻结果。换句话说,它并不考虑结果的可能位址,彻底地原创 2016-12-14 19:25:19 · 411 阅读 · 0 评论 -
[HPUOJ] 1152: 棋盘变换 [搜索]
题目描述给定一个4*4的01棋盘,1代表棋子,0代表空格,棋子1每次可以移动到相邻上下左右四个位置的空格。然后再给定你目标棋盘,问你最少在多少步能把当前棋盘变成目标棋盘状态。输入第一行输入一个整数T,代表有T组测试数据。接下来给出只有0和1的4*4的当前棋盘和4*4的目标棋盘,中间有一个空行。输出输出一个整数表示最小的步数,若不能到达输出-1。样例输入1 0001 0011 1100 111原创 2017-06-26 13:16:57 · 581 阅读 · 0 评论 -
Knight Moves --bfs
BackgroundMr Somurolov, fabulous chess-gamer indeed, asserts that no one else but him can move knights from one position to another so fast. Can you beat him? The ProblemYour task is to write a program原创 2017-02-04 12:29:31 · 266 阅读 · 0 评论 -
Battle City
DescriptionMany of us had played the game “Battle city” in our childhood, and some people (like me) even often play it on computer now. What we are discussing is a simple edition of this game. Given a原创 2017-02-04 20:46:03 · 370 阅读 · 0 评论 -
Catch That Cow--bfs 与 优化
Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤ 100,00原创 2017-02-04 11:40:41 · 236 阅读 · 0 评论 -
The Game
One morning, you wake up and think: "I am such a good programmer. Why not make some money?'' So you decide to write a computer game. The game takes place on a rectangular board consisting of w * h s原创 2017-02-04 18:30:00 · 328 阅读 · 0 评论 -
【HZAU】1013 Yuchang and Zixiang ‘s maze 宽度优先搜索
Problem A: Yuchang and Zixiang ‘s mazeTime Limit: 2 Sec Memory Limit: 128 MB Submit: 907 Solved: 160 [Submit][Status][Web Board]DescriptionOne day , Yuchang and Zixiang go out of school to find so原创 2016-12-20 13:24:16 · 424 阅读 · 0 评论 -
【POJ】3122 Pie 二分搜索
Pie Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16158 Accepted: 5497 Special Judge Description My birthday is coming up and traditionally I'm ser原创 2016-12-30 13:29:37 · 3096 阅读 · 0 评论 -
超级赛亚ACMer 二分搜索 upper_bound
百小度是一个ACMer,也是一个超级赛亚人,每个ACMer都有一个战斗力,包括百小度。 所谓超级赛亚人的定义,是说如果在对抗中刚好接近极限状态,那就会激发斗志,实力提升. 具体来说,就是百小度现在要接受一些ACMer的挑战了,这些ACMer有n个人,第i个人的战斗力是aii。 百小度接下来可以自主安排与这n个ACMer的PK顺序,他要想在PK赛中赢过另外一个ACMer,就必须使得自己的战斗力不小于原创 2016-12-24 21:49:58 · 444 阅读 · 0 评论 -
【HDU】 5101 Select 二分搜索 upper_bound
Problem Description One day, Dudu, the most clever boy, heard of ACM/ICPC, which is a very interesting game. He wants to take part in the game. But as we all know, you can’t get good result without te原创 2016-12-23 17:23:57 · 320 阅读 · 0 评论 -
Hard Process 二分搜索
描述 You are given an array a with n elements. Each element of a is either 0 or 1.Let’s denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a).原创 2016-12-22 18:23:12 · 281 阅读 · 0 评论 -
The Frog's Games 二分搜索
描述 The annual Games in frogs’ kingdom started again. The most famous game is the Ironfrog Triathlon. One test in the Ironfrog Triathlon is jumping. This project requires the frog athletes to jump over原创 2016-12-22 16:43:17 · 289 阅读 · 0 评论 -
Subsequence 二分搜索
描述 A sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) are given. Write a program to find the minimal length of the原创 2016-12-22 11:42:21 · 259 阅读 · 0 评论 -
序列变换 二分搜索
描述 给定序列A={A1,A2,…,An}A={A1,A2,…,An}, 要求改变序列A中的某些元素,形成一个严格单调的序列B(严格单调的定义为:Bi#include<stdio.h> #include<algorithm> using namespace std; int n,a[100005]; bool check(int ans) { int last=a[0]-ans,now=原创 2016-12-22 10:23:36 · 674 阅读 · 1 评论 -
【POJ】3984 迷宫问题 BFS 与 DFS
问题它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。 Input一个5 × 5的二维数组,表示一个迷宫。数据保证有唯一解。 Output左上角到右下角的最短路径,格式如样例所示。 Sample Input0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 1 0 Sa原创 2016-12-21 20:42:02 · 350 阅读 · 0 评论 -
【POJ】3258 River Hopscotch 不仅仅是二分
River HopscotchTime Limit: 2000MS Memory Limit: 65536K Total Submissions: 12303 Accepted: 5271 DescriptionEvery year the cows hold an event featuring a peculiar version of hopscotch that involves c原创 2016-12-21 15:11:01 · 338 阅读 · 0 评论 -
二分搜索
二分搜索的时间复杂度为o(logn),仅适用于单调序列 while(top-low>1) { int m=(top+low)/2; if(a[m]<=n) low=m; if(a[m]>=n) top=m; } //结果 a[low]为小于等于n的最大值 //结果 a[top]为大于等于n的最小值 //lo原创 2016-12-14 22:01:02 · 215 阅读 · 0 评论 -
[HDU]-6060 RXD and dividing
RXD has a tree T, with the size of n. Each edge has a cost. Define f(S) as the the cost of the minimal Steiner Tree of the set S on tree T. he wants to divide 2,3,4,5,6,…n into k parts S1,S2,S3,…Sk,原创 2017-08-01 20:54:57 · 316 阅读 · 0 评论