搜索
winhcc
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
poj 2251
简单三位bfs找最短距离 #include<cstdio> #include<cstring> #include<queue> #include<iostream> using namespace std; int dx[6]={-1,1,0,0,0,0}; int dy[6]={0,0,-1,1,0,0}; int dz[6]={0,0,0,0,1...原创 2019-03-11 19:23:50 · 248 阅读 · 0 评论 -
Codeforces 1143B
给一个数n,求出 1- n 中所有的各位相乘的最大的值 以 390作为分析 最高位 只可能选 3 或者 2,并且选 2 的话后面的位数可以都选 9,(是不是很像数位dp?) 结果是 2 * 9 * 9 = 162 选3的话第二位可以选9 或者 8 ,依次类推 即可 #include<bits/stdc++.h> using namespace std; #define forn(i,...原创 2019-03-31 12:30:37 · 300 阅读 · 0 评论 -
Codeforces 1130C
求从(r1,c2)到(r2,c2) 的最小花费,连通的0可以任意走,否则要搭桥,搭桥的费用是两点的欧几里得距离,bfs两次,分别把和(r1,c1)、(r2,c2)相连的0打上标记,n<=50,因此可以n^4枚举。 #include<bits/stdc++.h> using namespace std; #define forn(i,n) for(int i = 0;i<in...原创 2019-03-22 20:07:15 · 271 阅读 · 0 评论 -
Codeforces 1105D
很好的搜索题,多个对象,每个对象可以一次走多步。问最后每个对象占了多少个格子。 每个对象一个队列,对于一个对象走不只一步的问题,先记录当前队列元素的个数m,一次只处理m个即可。 最后s可能到1e9,因此当队列中没有元素的时候就应该跳出循环,不然会T。 #include <bits/stdc++.h> #define f first #define s second using nam...原创 2019-03-22 17:14:54 · 190 阅读 · 0 评论 -
hdu 2181
dfs输出路径的问题,需要注意的是不能一边dfs一边输出,而是存在一个vector里面到一次搜索结束的时候一起输出,最后要注意的是若一开始从位置k开始,vis[k]不能设为1,因为要最后回到这个点。 最后要注意要按字典序输出,用链式向前星的时候把一个点的相连的其他点排个序即可。 最后不要反复加边,看看输入就知道了。 #include <cstdio> #include <cstr...原创 2019-03-19 21:11:54 · 244 阅读 · 0 评论 -
poj 3087
stl乱搞即可 #include <iostream> #include <cstring> #include <map> #include <cstdio> using namespace std; string s1,s2,goal,tem; map<string ,int> use; int n,step,len,f,cas=1; ...原创 2019-03-17 15:07:17 · 118 阅读 · 0 评论 -
poj 3126
bfs,把一个4位数的素数转换为另外一个4位数的素数,只能把4位中的一位变成另外的数字,中途的数字也必须是素数。 需要注意:pow()返回double,转为int会产生误差,所以能不用就不用,(所以要打表啊) #include <cstdio> #include <algorithm> #include <cstring> #include <cmath...原创 2019-03-17 15:58:30 · 272 阅读 · 0 评论 -
hdu 2612
很简单的bfs题,没想到还被卡了几下。 需要注意的是有的kcf两个人都到不了的话不能考虑在内 #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <vector> #define f first #define s sec...原创 2019-03-17 15:04:33 · 146 阅读 · 0 评论 -
poj 1426
基础的迭代加深搜索,没想到我的第一次居然献给了它!!! 还是比较简单的啦 #include <cstdio> #include <vector> using namespace std; int n,maxd; int ans[250]; int dfs(int mod,int step){ //printf("%d %d\n",mod,step); if(mod...原创 2019-03-16 17:05:09 · 141 阅读 · 0 评论 -
poj 3414
有点恶心的倒水模型,但只有两杯水,其实并不是很复杂。用数组记录路径,把6个动作分别对应上序号,bfs搞一搞就出来了 #include <cstdio> #include <queue> #include <vector> #include <cstring> #define f first #define s second using names...原创 2019-03-16 16:41:48 · 432 阅读 · 0 评论 -
poj 3009
搜索题,但是很容易误认为是bfs,由于物体可以沿一个方向持续移动,直到出界或遇到墙。所有每一次移动后可能形成一个新的状态,所以是dfs #include <cstdio> #include <cmath> #include <algorithm> using namespace std; int n,m,a[22][22],si,sj,ei,ej,ans; ...原创 2019-03-13 16:44:52 · 186 阅读 · 0 评论 -
poj 1321
n*n的棋盘上有若干空格,每个空格可以摆一个棋子,每行每列都只能摆一个,要摆k个,问有多少种摆法。 需要注意的是如果有一行全都没有空格,那么还是可以存在方案的,因为只要摆k个即可。 #include <cstdio> #include <cstring> int n,k,c[10],ans; char a[10][10]; void dfs(int step,int r...原创 2019-03-11 19:00:30 · 105 阅读 · 0 评论
分享