随笔分类 - 搜索
摘要:You are given an array aa consisting of nn integer numbers. You have to color this array in kk colors in such a way that: Each element of the array sh
阅读全文
摘要:“连连看”相信很多人都玩过。没玩过也没关系,下面我给大家介绍一下游戏规则:在一个棋盘中,放了很多的棋子。如果某两个相同的棋子,可以通过一条线连起来(这条线不能经过其它棋子),而且线的转折次数不超过两次,那么这两个棋子就可以在棋盘上消去。不好意思,由于我以前没有玩过连连看,咨询了同学的意见,连线不能从
阅读全文
摘要:Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on a board of size n × m cells, like this: Each cell contains
阅读全文
摘要:在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。 你的任务是,对于给定的N,求出有多少种合法的放置方法。 Input共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。Output共有若
阅读全文
摘要:Problem Description The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large re
阅读全文
摘要:定义一个二维数组: 它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。 Input 一个5 × 5的二维数组,表示一个迷宫。数据保证有唯一解。 Output 左上角到右下角的最短路径,格式如样例所示。 Sample Inpu
阅读全文
摘要:There is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two
阅读全文
摘要:Problem Description As a cute girl, Kotori likes playing ``Hide and Seek'' with cats particularly.Under the influence of Kotori, many girls and cats a
阅读全文
摘要:题目链接:https://vjudge.net/contest/277958#problem/K 题目大意:直线上的两个坐标N和K,其中从N出发到达K,可以变换为+1、-1或者*2,每变换一次坐标,需要花费一分钟,求最短时间到达K。 代码: 1 #include<iostream> 2 #inclu
阅读全文
摘要:题目链接:https://vjudge.net/contest/277958#problem/J 题意:每组测试案例给出两个数a,b,从数字a开始,每次只改变当前数中的一位数,使之仍为一个素数,问经过多少步骤能够得到数字b。 代码: 1 #include<algorithm> 2 #include<
阅读全文
摘要:题目:https://vjudge.net/contest/277958#problem/G 题意:输入一个val和n,然后n个数,然后求n个数相加等于val的值。 代码: 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring>
阅读全文
摘要:题目描述: 转载自:https://blog.csdn.net/h1021456873/article/details/54572767 题意: 给你一个转轮,有5种颜色,为了5中颜色的位置是确定的,为了方便处理我们用01234来表示绿,黑,红,蓝,白。轮子可以沿着它的方向滚动(只能是它当前的方向不
阅读全文
摘要:题目链接:https://vjudge.net/problem/POJ-2531 最大流-最小割问题: https://wenku.baidu.com/view/54323c030722192e4536f64f.html 题意:给出n个点(0-n-1),接下来n行,每行有n个数,第i行代表第i-1个
阅读全文
摘要:题目链接:http://poj.org/problem?id=3414 参考博客:https://blog.csdn.net/tigerisland45/article/details/52208174 代码实现:
阅读全文
摘要:题目链接:http://poj.org/problem?id=2488 题目解读:首先得弄清楚国际象棋中关于“马走日”的规则,如上图中的马,它的下一步的走法有8中,所以对每一个位置的马,它所能走的8个方向坐标设置为 dir[8][2]= {{-1,-2},{1,-2},{-2,-1},{2,-1},
阅读全文
摘要:详见转载博客:https://www.cnblogs.com/wzl19981116/p/9397203.html 1.dfs(深度优先搜索)是两个搜索中先理解并使用的,其实就是暴力把所有的路径都搜索出来,它运用了回溯,保存这次的位置,深入搜索,都搜索完了便回溯回来,搜下一个位置,直到把所有最深位置
阅读全文

浙公网安备 33010602011771号