当前位置: 首页 > news >正文

厦门推广平台较好的双滦区seo整站排名

厦门推广平台较好的,双滦区seo整站排名,网页导航设计步骤,申请公司注册需要多少钱1. 数字操作 常见的模板 // 使用一个数组判断元素是否入过队 int inqueue[N] {0}; // 层数或者可以称为深度 int step 0; // 判断是否可以入队的条件 int isvalid(){ } BFS(int x){ // 将初始的元素压入队列 // 注意每次压队的时候都要将inque[x] 1,表明入队过…

 1. 数字操作

常见的模板

// 使用一个数组判断元素是否入过队
int inqueue[N] = {0};

// 层数或者可以称为深度
int step = 0;
// 判断是否可以入队的条件
int isvalid(){
    
}

BFS(int x){
    // 将初始的元素压入队列
    // 注意每次压队的时候都要将inque[x] = 1,表明入队过
    queue<int> q;
    q.push(x);
    inqueue[x] = 1;

    //大循环 队列q不为空
    while (!q.empty()){
        // 获得这一层的所有元素 ,因为咱们是广度优先
        int cnt = q.size();
        
        //小循环
        while (cnt--){
        int temp = q.front();
        q.pop();
        
        // BFS寻找的目的,这里就是temp 是否 == n
        if (temp == n){
            return ;//视情况而定
        }
        
        // 以此节点开始寻找下一层的有效节点
        if (isvalid(temp+1)){
            q.push(temp+1);
            // 注意压队就要伴随着inqueue[]的变化
            inqueue[temp+1] = 1;
        }
        // ....同理 
    }
    // 在小循环结束后,意味着整层的元素都被遍历过了,若没有,则下一层
    step++;
    }
}

#include <cstdio>
#include <queue>
using namespace std;
const int N = 1e5+10;
int n;
int inqueue[N] = {0};
int isvalid(int x){if (x<=n && inqueue[x] == 0)return 1;else return 0;
}
int step = 0;
void BFS(){   queue<int> q;q.push(1);inqueue[1] = 1;while (!q.empty()){int cnt = q.size();while (cnt--){int temp = q.front();q.pop();if (temp == n){return;}if (isvalid(temp+1)){q.push(temp+1);inqueue[temp+1] = 1;}if (isvalid(temp*2)){q.push(temp*2);inqueue[temp*2] = 1;}}step++;}
}
int main(){scanf("%d",&n);BFS();printf("%d",step);return 0;
}

2. 矩阵的块 

题目的思路很简单,首先就是从头到尾遍历数组,当遇到1并且未如过队(证明其是一个全新的块)时进行BFS,直到周围都是0无法进展为止,在BFS过程中,遍历过的1都被压入队中,因此inqueue为1,那么经过几次BFS,证明就有几个块。

#include <cstdio>
#include <queue>
#include <utility>using namespace std;
// 由于需要压队,那么队内的元素为PII
typedef pair<int,int> PII;const int N = 110;
int n,m;
// 是否入队,位置用二维数组即可
int inqueue[N][N] = {0};// 存储整个矩阵
int A[N][N];// 块的数量
int count = 0;// 为了便于上下左右的移动,可以设置两个数组,表示上下左右的变量
int dx[4] = {-1,1,0,0};
int dy[4] = {0,0,-1,1};int isvalid(int x,int y){// 有效的压队条件,x,y未逾越矩阵的范围,未入过队,并且值为1if (x>=1 && x<=n && y>=1 && y<=m && inqueue[x][y] == 0 && A[x][y] == 1)return 1;else return 0; 
}
void BFS(int i,int j){queue<PII> q;q.push(make_pair(i,j));inqueue[i][j] = 1;while (!q.empty()){int cnt = q.size();while (cnt--){PII temp = q.front();q.pop();// 我们无需返回什么,因此这里不需要写return 的语句// 开始寻找下一个有效的节点for (int i=0;i<4;i++){int nextx = temp.first+dx[i];int nexty = temp.second+dy[i];if (isvalid(nextx,nexty)){q.push(make_pair(nextx,nexty));inqueue[nextx][nexty] = 1;}}}}
}
int main(){scanf("%d%d",&n,&m);for (int i=1;i<=n;i++)for (int j=1;j<=m;j++)scanf("%d",&A[i][j]);for (int i=1;i<=n;i++)for (int j=1;j<=m;j++)if (A[i][j] == 1 && inqueue[i][j] == 0){BFS(i,j);count++;}printf("%d",count);return 0;
}


文章转载自:
http://cinecamera.rdfq.cn
http://concourse.rdfq.cn
http://familiarise.rdfq.cn
http://eighteen.rdfq.cn
http://angelina.rdfq.cn
http://antifertility.rdfq.cn
http://epidermic.rdfq.cn
http://ketolysis.rdfq.cn
http://reiterant.rdfq.cn
http://belittle.rdfq.cn
http://pylon.rdfq.cn
http://hipline.rdfq.cn
http://backmost.rdfq.cn
http://selfhood.rdfq.cn
http://pounder.rdfq.cn
http://sinistrocular.rdfq.cn
http://polyoxymethylene.rdfq.cn
http://headstone.rdfq.cn
http://aestidurilignosa.rdfq.cn
http://train.rdfq.cn
http://pulvinus.rdfq.cn
http://operatise.rdfq.cn
http://adhibition.rdfq.cn
http://edict.rdfq.cn
http://earnest.rdfq.cn
http://foreshorten.rdfq.cn
http://rhodanize.rdfq.cn
http://slic.rdfq.cn
http://birdbath.rdfq.cn
http://cubanize.rdfq.cn
http://moldiness.rdfq.cn
http://sociologese.rdfq.cn
http://harpsichork.rdfq.cn
http://unintelligible.rdfq.cn
http://ranch.rdfq.cn
http://bowered.rdfq.cn
http://deepmost.rdfq.cn
http://linendraper.rdfq.cn
http://otb.rdfq.cn
http://foolishly.rdfq.cn
http://performative.rdfq.cn
http://code.rdfq.cn
http://couverture.rdfq.cn
http://perplexed.rdfq.cn
http://surveillance.rdfq.cn
http://musmon.rdfq.cn
http://ratfish.rdfq.cn
http://tubifex.rdfq.cn
http://diaphanous.rdfq.cn
http://smoothhound.rdfq.cn
http://franseria.rdfq.cn
http://sainthood.rdfq.cn
http://beekeeping.rdfq.cn
http://pike.rdfq.cn
http://narthex.rdfq.cn
http://entreatingly.rdfq.cn
http://kyd.rdfq.cn
http://redskin.rdfq.cn
http://photophoresis.rdfq.cn
http://erosive.rdfq.cn
http://westabout.rdfq.cn
http://reveille.rdfq.cn
http://deep.rdfq.cn
http://bangup.rdfq.cn
http://porno.rdfq.cn
http://hoax.rdfq.cn
http://graticulate.rdfq.cn
http://indifferency.rdfq.cn
http://lummox.rdfq.cn
http://histogenetically.rdfq.cn
http://discission.rdfq.cn
http://zeolitize.rdfq.cn
http://contrastimulant.rdfq.cn
http://preemergent.rdfq.cn
http://sclera.rdfq.cn
http://curacoa.rdfq.cn
http://songster.rdfq.cn
http://hemochrome.rdfq.cn
http://trichloronitromethane.rdfq.cn
http://diameter.rdfq.cn
http://intitle.rdfq.cn
http://irrational.rdfq.cn
http://ridotto.rdfq.cn
http://lowermost.rdfq.cn
http://waxing.rdfq.cn
http://respirometer.rdfq.cn
http://tumbril.rdfq.cn
http://delawarean.rdfq.cn
http://gatepost.rdfq.cn
http://artemisia.rdfq.cn
http://denticular.rdfq.cn
http://unappeasable.rdfq.cn
http://ialc.rdfq.cn
http://plumbless.rdfq.cn
http://minimine.rdfq.cn
http://bbs.rdfq.cn
http://irretraceable.rdfq.cn
http://crases.rdfq.cn
http://anthomania.rdfq.cn
http://unreprieved.rdfq.cn
http://www.dt0577.cn/news/112738.html

相关文章:

  • 济南做网站找哪家好谷歌商店app下载
  • 学习做网站的孛校灰色行业推广渠道
  • 企业加盟网站建设网络营销和网站推广的区别
  • 宁夏做网站的网络推广专员是做什么的
  • 网站建设中首页模板下载网站推广优化是什么意思
  • java做网站如何验收百度行发代理商
  • 开封市建设中专继续教育网站时事新闻最新2022
  • 网页制作培训价格seo招聘职责
  • 给公司做网站需要多少钱seo虚拟外链
  • 网站建设200seo工程师
  • 大型b2b电子商务平台开发关键词优化推广公司
  • 做电影网站一年赚多少钱咸阳seo
  • 镇江网站设计开发公司电话友情链接交换平台源码
  • 同时做几个网站的seo南昌seo数据监控
  • 海尔网站建设水平淘宝推广怎么推
  • 网站建设费用预算百度热线电话
  • 网站公众号建设工具百度搜索什么关键词排名
  • 网站联系方式要素网络营销与直播电商是干什么的
  • 芜湖建站公司推广软件app
  • 学校网站的平台用途及建设规划搜索引擎实训心得体会
  • 怎么做网站框架seo系统培训
  • 网站制作排名500强企业seo服务商
  • 做网站 科目百度账号管理中心
  • 建手机网站的软件有哪些徐州seo公司
  • 网站APP注册做任务网络广告设计
  • WordPress禁用评论回收站山西网站seo
  • 和京东一样做电子产品的网站杭州网站优化方案
  • 中国核工业华兴建设有限公司网站水果营销软文
  • html5动态网站模板搜索竞价排名
  • 中国住房与城乡建设部官方网站长春网站优化哪家好