随笔分类 -  广搜

摘要:广搜,挨个遍历,记录起点和终点,下一个的起点等于终点+1 #include<bits/stdc++.h>using namespace std;int xx[4]={0,0,1,-1},yy[4]={1,-1,0,0};int kt,s=0,kts,ktts;char c;int i,j,n,a[1 阅读全文
posted @ 2022-08-25 17:20 TheMagician 阅读(116) 评论(0) 推荐(0)
摘要:根据题意,我们可以从0,0遍历,将最外围圈设为1,将所有0设为1 最后相加 围成的圈外一定和边相靠 #include<bits/stdc++.h>using namespace std;int i,j,a[20][20],s=0;char c;void pd(int x,int y){ if(x+1 阅读全文
posted @ 2022-08-24 17:23 TheMagician 阅读(144) 评论(0) 推荐(0)
摘要:将所有的0替换为2,从边缘进行搜索,把圈外的2都换成0 外圈的0一定和边相邻 扩大边界,以便于将边界上单独的0标记。 #include<bits/stdc++.h>using namespace std;int n,i,j,a[50][50],ii,jj,bj,f,bjj[50];void pd(i 阅读全文
posted @ 2022-08-24 17:05 TheMagician 阅读(72) 评论(0) 推荐(0)
摘要:用字符分离,再从头遍历,若不是0,则s+1,函数,并去其他方向看是否有不是0的数,若有,则变0,函数,若没有,退出函数,继续遍历 #include<bits/stdc++.h>using namespace std;char a[200][200]; int i,j;int n,m,s=0;int 阅读全文
posted @ 2022-08-24 11:42 TheMagician 阅读(147) 评论(0) 推荐(0)
摘要:用两个变量,一个步数,一个下一步步数的总数,广搜 注意:数组开大 #include<bits/stdc++.h>using namespace std;int dx[10]={-2,-2,-1,-1,2,2,1,1};int dy[10]={1,-1,2,-2,1,-1,2,-2};long lon 阅读全文
posted @ 2022-08-24 11:31 TheMagician 阅读(58) 评论(0) 推荐(0)