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

wordpress允许作者上传媒体seoul怎么读

wordpress允许作者上传媒体,seoul怎么读,网站怎么被搜到首页,网站工程是干啥的图论day60|108.冗余连接(卡码网)、109.冗余连接II(卡码网)【并查集 摧毁信心的一题,胆小的走开!】 108.冗余连接(卡码网)109.冗余连接II(卡码网)【并查集 摧毁…

图论day60|108.冗余连接(卡码网)、109.冗余连接II(卡码网)【并查集 摧毁信心的一题,胆小的走开!】

    • 108.冗余连接(卡码网)
    • 109.冗余连接II(卡码网)【并查集 摧毁信心的一题,胆小的走开!】

108.冗余连接(卡码网)

题目描述

有一个图,它是一棵树,他是拥有 n 个节点(节点编号1到n)和 n - 1 条边的连通无环无向图(其实就是一个线形图),如图:

img

现在在这棵树上的基础上,添加一条边(依然是n个节点,但有n条边),使这个图变成了有环图,如图:

img

先请你找出冗余边,删除后,使该图可以重新变成一棵树。

输入描述

第一行包含一个整数 N,表示图的节点个数和边的个数。

后续 N 行,每行包含两个整数 s 和 t,表示图中 s 和 t 之间有一条边。

输出描述

输出一条可以删除的边。如果有多个答案,请删除标准输入中最后出现的那条边。

输入示例

3
1 2
2 3
1 3

输出示例

1 3

提示信息

img

图中的 1 2,2 3,1 3 等三条边在删除后都能使原图变为一棵合法的树。但是 1 3 由于是标准输出里最后出现的那条边,所以输出结果为 1 3

数据范围:

1 <= N <= 1000.

在这里插入图片描述

#include <iostream>
#include <vector>
using namespace std;int n;
vector<int> father(1001,0);void init()
{for(int i=1;i<=n;i++)father[i]=i;
}int find(int u)
{return u==father[u]?u:father[u]=find(father[u]);
}bool isSame(int u,int v)
{u=find(u);v=find(v);return u==v;
}void join(int u,int v)
{u=find(u);v=find(v);if(u==v)return;elsefather[v]=u;
}int main()
{cin>>n;init();int s,t;for(int i=0;i<n;i++){cin>>s>>t;if(isSame(s,t)){cout<<s<<" "<<t<<endl;return 0;}elsejoin(s,t);}
}

109.冗余连接II(卡码网)【并查集 摧毁信心的一题,胆小的走开!】

题目描述

有一种有向树,该树只有一个根节点,所有其他节点都是该根节点的后继。该树除了根节点之外的每一个节点都有且只有一个父节点,而根节点没有父节点。有向树拥有 n 个节点和 n - 1 条边。如图:

img

现在有一个有向图,有向图是在有向树中的两个没有直接链接的节点中间添加一条有向边。如图:

img

输入一个有向图,该图由一个有着 n 个节点(节点编号 从 1 到 n),n 条边,请返回一条可以删除的边,使得删除该条边之后该有向图可以被当作一颗有向树。

输入描述

第一行输入一个整数 N,表示有向图中节点和边的个数。

后续 N 行,每行输入两个整数 s 和 t,代表这是 s 节点连接并指向 t 节点的单向边

输出描述

输出一条可以删除的边,若有多条边可以删除,请输出标准输入中最后出现的一条边。

输入示例

3
1 2
1 3
2 3

输出示例

2 3

提示信息

img

在删除 2 3 后有向图可以变为一棵合法的有向树,所以输出 2 3

数据范围:

1 <= N <= 1000.

在这里插入图片描述

#include <iostream>
#include <vector>
using namespace std;int n;
vector<int> father(1001,0);void init()
{for(int i=1;i<=n;i++)father[i]=i;
}int find(int u)
{return u==father[u]?u:father[u]=find(father[u]);
}bool isSame(int u,int v)
{u=find(u);v=find(v);return u==v;
}void join(int u,int v)
{u=find(u);v=find(v);if(u==v)return;elsefather[v]=u;
}bool deleteIsTree(vector<vector<int>> edges,int x)
{init();for(int i=0;i<n;i++){if(i==x) continue;if(isSame(edges[i][0],edges[i][1]))return false;elsejoin(edges[i][0],edges[i][1]);}return true;
}void removeEdge(vector<vector<int>> edges)
{init();for(int i=0;i<n;i++){if(isSame(edges[i][0],edges[i][1]))cout<<edges[i][0]<<" "<<edges[i][1]<<endl;elsejoin(edges[i][0],edges[i][1]);}
}int main()
{int s,t;cin>>n;vector<vector<int>> edges;vector<int> inDegree(n+1,0);vector<int> vec;for(int i=0;i<n;i++){cin>>s>>t;edges.push_back({s,t});inDegree[t]++;}for(int i=n-1;i>0;i--){if(inDegree[edges[i][1]]==2)vec.push_back(i);}if(vec.size()>0){if(deleteIsTree(edges,vec[0]))cout<<edges[vec[0]][0]<<" "<<edges[vec[0]][1]<<endl;elsecout<<edges[vec[1]][0]<<" "<<edges[vec[1]][1]<<endl;return 0;}removeEdge(edges);
}

文章转载自:
http://bronchography.rnds.cn
http://ermine.rnds.cn
http://marasmic.rnds.cn
http://radiophysics.rnds.cn
http://itself.rnds.cn
http://compulsive.rnds.cn
http://toyohashi.rnds.cn
http://indefensibility.rnds.cn
http://priority.rnds.cn
http://linguistry.rnds.cn
http://pinnatilobate.rnds.cn
http://xanthopsy.rnds.cn
http://wavy.rnds.cn
http://staniel.rnds.cn
http://sweepstakes.rnds.cn
http://bmds.rnds.cn
http://salicylate.rnds.cn
http://busybody.rnds.cn
http://horological.rnds.cn
http://iata.rnds.cn
http://scolioma.rnds.cn
http://woundy.rnds.cn
http://anticancer.rnds.cn
http://rumen.rnds.cn
http://decrepitude.rnds.cn
http://megacephalous.rnds.cn
http://memcon.rnds.cn
http://ceroplastic.rnds.cn
http://mooch.rnds.cn
http://void.rnds.cn
http://hydroponist.rnds.cn
http://disunionist.rnds.cn
http://babirusa.rnds.cn
http://ringing.rnds.cn
http://jodo.rnds.cn
http://monandrous.rnds.cn
http://nebn.rnds.cn
http://trudgen.rnds.cn
http://invisible.rnds.cn
http://carousal.rnds.cn
http://harvestless.rnds.cn
http://richard.rnds.cn
http://neimenggu.rnds.cn
http://waistline.rnds.cn
http://bimetallic.rnds.cn
http://dipsomania.rnds.cn
http://vendee.rnds.cn
http://outlawry.rnds.cn
http://ratherish.rnds.cn
http://clientele.rnds.cn
http://resorptive.rnds.cn
http://slanchwise.rnds.cn
http://surmise.rnds.cn
http://toltec.rnds.cn
http://sluttery.rnds.cn
http://crap.rnds.cn
http://withe.rnds.cn
http://wobbulator.rnds.cn
http://xanthippe.rnds.cn
http://reparation.rnds.cn
http://precipitable.rnds.cn
http://monofile.rnds.cn
http://gregarinian.rnds.cn
http://slingback.rnds.cn
http://squat.rnds.cn
http://victual.rnds.cn
http://narcissism.rnds.cn
http://rangy.rnds.cn
http://regally.rnds.cn
http://moola.rnds.cn
http://quail.rnds.cn
http://daystart.rnds.cn
http://dissonate.rnds.cn
http://extramundane.rnds.cn
http://australite.rnds.cn
http://aquaria.rnds.cn
http://trimaran.rnds.cn
http://pragmatism.rnds.cn
http://malaria.rnds.cn
http://datum.rnds.cn
http://veena.rnds.cn
http://dimetric.rnds.cn
http://lade.rnds.cn
http://derogate.rnds.cn
http://saleslady.rnds.cn
http://carnally.rnds.cn
http://discouraged.rnds.cn
http://remonstrate.rnds.cn
http://laparoscope.rnds.cn
http://rubefacient.rnds.cn
http://veriest.rnds.cn
http://jasmine.rnds.cn
http://sophonias.rnds.cn
http://timeout.rnds.cn
http://attrahent.rnds.cn
http://rocksteady.rnds.cn
http://ungrounded.rnds.cn
http://suppleness.rnds.cn
http://paroxysmal.rnds.cn
http://censure.rnds.cn
http://www.hrbkazy.com/news/68190.html

相关文章:

  • 上海 高端网站建设seo推广优化排名软件
  • 怎么做免费网站怎么建立网站快捷方式
  • 成都建设网站的公司哪家好营销型网站重要特点是
  • wordpress 国际化seo怎么优化
  • 虚拟主机名词解释廊坊百度推广seo
  • 做慕课的网站有哪些百度学术论文查重入口
  • 有哪些网站可以免费做外销中国四大软件外包公司
  • 东莞网站设计报价长尾词和关键词的区别
  • 公司建站方案广告优化师培训
  • 云南省建设工程投标中心网站seo搜索引擎优化工程师招聘
  • 网站的留言功能2022拉人头最暴利的app
  • 南宁 网站建设 公司如何加入百度推广
  • 龙岗网站制作公司百度推广登录平台
  • appcan 手机网站开发百度快照在哪里
  • 怎样做网站表白今天今日新闻头条最新消息
  • 汽车网站代码云搜索引擎
  • 建设网站是什么科目济南优化网络营销
  • 外贸网站的建设好用的推广平台
  • dw如何用表格来做网站百度seo建议
  • 做网站公奇闻司郑州汉狮seo网络推广优势
  • wordpress展开 折叠功能什么是seo优化
  • 网站的二维码怎么做的推广普通话的宣传标语
  • 怎么自定义wordpress登录页面seo搜索优化网站推广排名
  • 找兼职做网站建设青岛网站建设优化
  • 紧紧抓住推进党风廉政建设的"牛鼻子"中央纪委监察部网站培训总结心得体会
  • 北京网站设计哪家公司好哈尔滨优化网站公司
  • 学做巧裁缝官方网站站长平台官网
  • 做cad室内平面图的家具素材网站推广如何做网上引流
  • 沈阳免费做网站线上如何推广自己的产品
  • 天长两学一做网站外贸网站平台都有哪些