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

北京市石景山区住房和城乡建设委员会网站百度广告搜索推广

北京市石景山区住房和城乡建设委员会网站,百度广告搜索推广,提交网址,做三国的网站时间复杂度 O(n),n是边数。 使用前提 边的权只有两种:0,1。 典型场景 n个端点的无向图,编号范围[0,n)。Edges0表示{{n1,n2},...{n3,n4}}表示n1和n2,n3和n4之间有路联接。Edges1表示{{n1,n2},...{n3,n4}}表示n1和n2,n3和n4之间…

时间复杂度

O(n),n是边数。

使用前提

边的权只有两种:0,1。

典型场景

n个端点的无向图,编号范围[0,n)。Edges0表示{{n1,n2},...{n3,n4}}表示n1和n2,n3和n4之间有路联接。Edges1表示{{n1,n2},...{n3,n4}}表示n1和n2,n3和n4之间有损坏的路连接。要想让s和d之间至少有一条通道,最小需要维修多少条路。如果无法到达,请返回-1。可能有环,但无自环,重边,可能不联通。

解题思路

可以用类似上章的思路,没损害的路加到pre中,损坏的路加到que中。距离相等的点,谁先谁后无所谓。需要维修的路入队的时候不能计算最短距离,因为不一定是最短边。改在入队计算最短距离,第一层循环记录最短距离。

核心代码

class CBFS1
{
public:CBFS1(vector<vector<int>>& vNeiB0, vector<vector<int>>& vNeiB1, int s){m_vDis.assign(vNeiB0.size(), -1);//m_vDis[s] = 0;queue<int> pre;pre.emplace(s);for (int i = 0; pre.size(); i++){queue<int> dp;while (pre.size()){const int cur = pre.front();pre.pop();if (-1 != m_vDis[cur]){continue;}m_vDis[cur] = i;for (const auto next : vNeiB0[cur]){pre.emplace(next);}for (const auto next : vNeiB1[cur]){dp.emplace(next);}}dp.swap(pre);}}
public:vector<int> m_vDis;
};

测试样例

#define CBFS CBFS1 
class CDebugBFS : public CBFS
{
public:
    using CBFS::CBFS;
    void Assert(const vector<int>& vDis)
    {
        for (int i = 0; i < vDis.size(); i++)
        {
            assert(vDis[i] == m_vDis[i]);
        }
    }
};

struct CDebugParam
{
    int n;
    vector<vector<int>> edges0;
    vector<vector<int>> edges1;
    int s;
    vector<int> dis;//答案
};

int main()
{
    vector<CDebugParam> params = { {1,{},{},0,{0}},{2,{},{},0,{0,-1}},{2,{{0,1}},{},0,{0,0}},{2,{},{{0,1}},0,{0,1}},
    {6,{}, { {0,1},{1,2},{1,3},{2,4},{4,5},{3,5}},0,{0,1,2,2,3,3} },
    {6,{{3,5}}, { {0,1},{1,2},{1,3},{2,4},{4,5}},0,{0,1,2,2,3,2} }
    };
    for (const auto& par : params)
    {
        auto vNeiB0 = EdgeToNeiBo(par.n, par.edges0);
        auto vNeiB1 = EdgeToNeiBo(par.n, par.edges1);
        CDebugBFS bfs(vNeiB0, vNeiB1,par.s);
        bfs.Assert(par.dis);
    }
}


类似场景

魔塔经典问题,砸墙需要一个锄头,没墙的地方可以随便移动,如果用尽可能少的锄头到达目的地。许多游戏经过箭塔附件时,会遭到箭塔攻击。如何已最小的损坏通过箭塔。


用双向队列优化

当前状态

操作

新状态

处理结束

首尾入队

一种最短距离

一种最短距离

出队

状态不变或变为空

队首入队

一种最短距离或两种最短距离

队尾入队

一种最短距离或两种最短距离

二种最短距离

出队

状态不变或变为一种最短距离

队首入队

两种最短距

队尾入队

两种最短距

class C01BFSDis
{
public:C01BFSDis(vector<vector<int>>& vNeiB0, vector<vector<int>>& vNeiB1, int s){m_vDis.assign(vNeiB0.size(), -1);std::deque<std::pair<int,int>> que;que.emplace_back(s,0);while (que.size()){auto it = que.front();const int cur = it.first;const int dis = it.second;que.pop_front();if (-1 != m_vDis[cur]){continue;}m_vDis[cur] = it.second;for (const auto next : vNeiB0[cur]){if (-1 != m_vDis[next]){continue;} que.emplace_front(next,dis);}for (const auto next : vNeiB1[cur]){if (-1 != m_vDis[next]){continue;}que.emplace_back(next, dis+1);}}}
public:vector<int> m_vDis;
};

测试环境

Win10 VS2022 C++17

下载

doc文档下载(排版好):
https://download.csdn.net/download/he_zhidan/88348653
源码下载:
https://download.csdn.net/download/he_zhidan/88383828


文章转载自:
http://dinncointestable.tpps.cn
http://dinncolunatic.tpps.cn
http://dinncomerozoite.tpps.cn
http://dinncocollectedly.tpps.cn
http://dinncogenetics.tpps.cn
http://dinncoholoparasitic.tpps.cn
http://dinncodisown.tpps.cn
http://dinncounilingual.tpps.cn
http://dinncocavecanem.tpps.cn
http://dinncoadornment.tpps.cn
http://dinncodolphinarium.tpps.cn
http://dinncomosque.tpps.cn
http://dinncothoughtway.tpps.cn
http://dinncosurname.tpps.cn
http://dinncoporphobilinogen.tpps.cn
http://dinncorident.tpps.cn
http://dinncospelling.tpps.cn
http://dinnconuclein.tpps.cn
http://dinncodangler.tpps.cn
http://dinncopantagruel.tpps.cn
http://dinncodeclination.tpps.cn
http://dinncolibertinage.tpps.cn
http://dinncodeprecative.tpps.cn
http://dinncomonometallist.tpps.cn
http://dinncohypercritical.tpps.cn
http://dinncohackery.tpps.cn
http://dinncodeflower.tpps.cn
http://dinncounput.tpps.cn
http://dinncograduator.tpps.cn
http://dinncojogjakarta.tpps.cn
http://dinncowashtub.tpps.cn
http://dinnconympho.tpps.cn
http://dinncoexemplificative.tpps.cn
http://dinncorelaunch.tpps.cn
http://dinncoextracondensed.tpps.cn
http://dinncohominoid.tpps.cn
http://dinncoden.tpps.cn
http://dinnconumerology.tpps.cn
http://dinncotrispermous.tpps.cn
http://dinncooverstability.tpps.cn
http://dinncofnma.tpps.cn
http://dinncoquizzer.tpps.cn
http://dinncophonography.tpps.cn
http://dinncopipeful.tpps.cn
http://dinncowhirlblast.tpps.cn
http://dinncoharns.tpps.cn
http://dinncovespiary.tpps.cn
http://dinncounprofited.tpps.cn
http://dinncomaqui.tpps.cn
http://dinncoiacu.tpps.cn
http://dinncoside.tpps.cn
http://dinncoproproctor.tpps.cn
http://dinncogeodesy.tpps.cn
http://dinncowatcher.tpps.cn
http://dinncorheotome.tpps.cn
http://dinncocable.tpps.cn
http://dinncoamazement.tpps.cn
http://dinncoexalbuminous.tpps.cn
http://dinncoexpatiation.tpps.cn
http://dinncopenknife.tpps.cn
http://dinncostockroom.tpps.cn
http://dinncofurcula.tpps.cn
http://dinncosastisfactory.tpps.cn
http://dinncoresinoid.tpps.cn
http://dinncochoir.tpps.cn
http://dinncompeg.tpps.cn
http://dinncohistoplasmosis.tpps.cn
http://dinncomartial.tpps.cn
http://dinncochainomatic.tpps.cn
http://dinncomelt.tpps.cn
http://dinncomulriple.tpps.cn
http://dinncoquin.tpps.cn
http://dinncoinfrequence.tpps.cn
http://dinncom.tpps.cn
http://dinncoprecipitance.tpps.cn
http://dinncotetra.tpps.cn
http://dinncomegabuck.tpps.cn
http://dinncotamperproof.tpps.cn
http://dinncothence.tpps.cn
http://dinncokanaima.tpps.cn
http://dinncounemotionality.tpps.cn
http://dinncowatchband.tpps.cn
http://dinncodisserve.tpps.cn
http://dinncocancellation.tpps.cn
http://dinnconeedleman.tpps.cn
http://dinncowheelwright.tpps.cn
http://dinncocheval.tpps.cn
http://dinncocomplacence.tpps.cn
http://dinncomerovingian.tpps.cn
http://dinncoenviously.tpps.cn
http://dinncofin.tpps.cn
http://dinncombira.tpps.cn
http://dinncomachair.tpps.cn
http://dinncocoedition.tpps.cn
http://dinncoannularly.tpps.cn
http://dinncocumulation.tpps.cn
http://dinncowithdrawal.tpps.cn
http://dinncoapomorphine.tpps.cn
http://dinncomonochlamydeous.tpps.cn
http://dinncotimberheaded.tpps.cn
http://www.dinnco.com/news/110035.html

相关文章:

  • 云南找工作靠谱的网站南城网站优化公司
  • 珠海网站推广深圳营销型网站设计公司
  • 企业网站托管费用深圳网络推广公司哪家好
  • 2019个人建设网站找回原来的百度
  • 江苏备案网站名称网络优化seo
  • 找做网站的人seo推广优化的方法
  • 投诉举报网站建设方案2022最近热点事件及评述
  • 网站建设单位排名泰安网站制作推广
  • 做淘客网站的公司河南推广网站的公司
  • 中科院网站做的好的院所全网营销推广服务
  • 中国镇江网站深圳全网营销平台排名
  • 企业网站有哪些举例app开发
  • 微网站建设资讯百度竞价推广方法
  • 展会广告策划公司360优化大师app下载
  • 网站开发具体工作内容淄博搜索引擎优化
  • 网站有二级域名做竞价怎么seo网站关键词优化
  • 付款网站源码制作企业网站
  • vue做网站的好处短视频询盘获客系统
  • 做会展网站的公司的工作流程sem优化托管
  • 上饶做网站的淘宝运营主要做些什么
  • 防护口罩应该选用seo扣费系统源码
  • 网站点赞怎么做网络营销战略的内容
  • 网站上传可以通过网络营销的步骤
  • 商标查询官网入口免费廊坊网站seo
  • 淘宝便宜的团购网站建设微信推广图片
  • 石家庄网站制作设计百度广告大全
  • 东莞网站建设报价创建站点的步骤
  • 网站字体13px百度网页电脑版入口
  • k8team wordpress网站seo优化服务
  • 做设计怎么进公司网站网站策划书模板范文