![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
【搜索】
文章平均质量分 78
__流影
读书、探知、成长、做有意义的事!
展开
-
素数环 南工acm(STL:next_permutation)
原来用C++ STL:next_permutation做的,每生成一个序列判断一个,结果超时,不过还是写下来吧,上一篇深搜的代码AC了# include # include using namespace std;bool sushu[]={0,0,1,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0原创 2013-04-09 21:04:41 · 831 阅读 · 0 评论 -
NYOJ 499 迷宫
题目链接:here~~不知道为什么,用方向数组会超时,改成if枚举方向就AC了 #include #include #include using namespace std;int map[10][10];bool vis[10][10];int res, n, m;void dfs(int i, int j){ int x, y; if (i==n&&原创 2013-05-02 20:55:35 · 732 阅读 · 0 评论 -
擅长排列的小明 南工19
题目链接:here~~#include using namespace std;int n,m, a[10];bool bz[10];//标记数字是否已经被用过void DFS(int k){ if (k==n)//搜出来的长度等于要求的长度,输出该序列,由于是从小到大搜索的所以输出的时候也是从小到大的 { for (int i=0; i<n; i++原创 2013-04-17 11:32:01 · 536 阅读 · 0 评论 -
NYOJ 图像有用区域 南工92
题目链接:here~~首先有一个比较明确的思路:对矩形四周的每个点向周围进行搜索,遇到0则停止,把不为0的数变为0。看数据量的大小用深搜的话肯定栈溢出RTE,所以选择用广搜!代码如下:#include #include #include #include using namespace std;int map[970][1450];struct point{ in原创 2013-04-25 12:14:07 · 586 阅读 · 0 评论 -
三个水杯 南工21
BFS:# include # include # include using namespace std;int vis[102][102][102];//标记算出的水杯状态是否被访问过struct cup //水杯结构体{ int a, b, c, count; bool operator < (cup x) const { return count>x.coun原创 2013-04-13 17:13:34 · 691 阅读 · 0 评论 -
坦克大战(最短时间和最短路径输出)
# include # include # include using namespace std;int map[302][302];bool vis[302][302];# include struct data{ int x, y, count; bool operator < (data a)const { return count>a.count; }}di原创 2013-04-12 17:22:29 · 1069 阅读 · 0 评论 -
最少步数 南工acm58
先把距离为1可以到的位置存起来,然后由距离为一的位置找距离为2的位置,再由距离为2的位置找距离为3的位置存起来。。。每次找完位置后,判断要到的地方在不在这次找到的距离为d的位置里,如果在,就结束,输出d,不在,就继续找!# include # include # include using namespace std;bool map[9][9]={ {1,1,1,1,1原创 2013-04-10 17:27:37 · 828 阅读 · 0 评论 -
南工acm 20 吝啬的国度
#include#include#include#includeusing namespace std;int res[100005];//记录终点的前一个城市vectorv[100005];//相当于开了一个二维的数组,共有100005行,v[x].push_back(y)即在第x行尾部添加元素yvoid DFS(int cur){ for(int i = 0; i < v[c原创 2013-04-10 12:33:58 · 914 阅读 · 0 评论 -
素数环 南工488
# include # include using namespace std;bool sushu[]={0, //将所有可能的和是否为素数存起来,和最大380,1,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0};int a[21], r原创 2013-04-09 20:50:44 · 941 阅读 · 1 评论