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

大朗疫情最新情况今天seo搜索引擎优化方法

大朗疫情最新情况今天,seo搜索引擎优化方法,哈尔滨市建设工程信息网官网,有初中生做的网站吗图算法刷到这块,感觉像是走了一段黑路快回到家一样,看到这三个一直分不太清总是记混的名字,我满脑子想起的是大学数据结构课我坐在第一排,看着我班导一脸无奈,心想该怎么把这个知识点灌进木头脑袋里边呢。有很多算法我…

图算法刷到这块,感觉像是走了一段黑路快回到家一样,看到这三个一直分不太清总是记混的名字,我满脑子想起的是大学数据结构课我坐在第一排,看着我班导一脸无奈,心想该怎么把这个知识点灌进木头脑袋里边呢。有很多算法我当时想不明白,感觉这样不对劲,这咋变一变就能找到么。但是现在想来,当时确实没必要想得太明白,如果我早知道这些知识在过了短短一两年之后我又会以陌生人的身份重新认识他们,当时就该转过头去,和我舍友大聊特聊离谱的八卦,让谢导早点放弃教会我们这个想法。

  • 生成树就是在图中找到一棵包含图中所有节点的树
  • 生成树是含有图中所有顶点的无环连通子图
  • 所有可能的生成树中,权重和最小的那棵生成树就叫「最小生成树」

1584. 连接所有点的最小费用Kruskal

class Solution {public int minCostConnectPoints(int[][] points) {int n = points.length;List<Edge> edges = new ArrayList<Edge>();DisjoinSetUnion dsu = new DisjoinSetUnion(n);for(int i=0;i<n;i++){for(int j=i+1;j<n;j++){edges.add(new Edge(i,j,dist(points,i,j)));} }// 升序Collections.sort(edges, new Comparator<Edge>() {public int compare(Edge edge1, Edge edge2) {return edge1.weight - edge2.weight;}});int ret = 0; int num = 0;for(Edge edge:edges){int x = edge.start;int y = edge.end;int weight = edge.weight;if(dsu.unionSet(x,y)){ret += weight;num++;if(num==n-1){break;}}}return ret;}public int dist(int[][] points,int i,int j){int weight = Math.abs(points[i][0]-points[j][0]) + Math.abs(points[i][1]-points[j][1]);return weight;} 
}class DisjoinSetUnion{int[] parent;int[] rank;int n;public DisjoinSetUnion(int n){this.n = n;this.rank = new int[n];Arrays.fill(this.rank,1);this.parent = new int[n];for(int i=0;i<n;i++){this.parent[i] = i;}}public int find(int x){if(parent[x]!=x){parent[x] = find(parent[x]);}return parent[x];}public boolean unionSet(int x, int y){int px = find(x);int py = find(y);// 是连通的,当节点联通后就会有共同的parent,说明这两个点已经被加入到树中了,没加入的话parent是自身if(px == py){return false;}else{if(rank[px]<rank[py]){int temp = px;px = py;py = temp;}rank[px] += rank[py];parent[py] = px;return true;              }}
}class Edge{int start;int end;int weight;public Edge(int start,int end,int weight){this.start = start;this.end = end;this.weight = weight;}
}

1584. 连接所有点的最小费用Prim

class Solution {public int minCostConnectPoints(int[][] points) {int n = points.length;List<int[]>[] graph =buildGraph(n,points);Prim prim = new Prim(graph);int ret = prim.weightSum();return ret;}List<int[]>[] buildGraph(int n,int[][] points){List<int[]>[] graph = new LinkedList[n];for(int i=0;i<n;i++){graph[i] = new LinkedList<int[]>();}for(int i=0;i<n;i++){for(int j=i+1;j<n;j++){int xi = points[i][0]; int yi = points[i][1];int xj = points[j][0]; int yj = points[j][1];int weight = Math.abs(xi-xj) + Math.abs(yi-yj);graph[i].add(new int[]{i,j,weight});graph[j].add(new int[]{j,i,weight});}}return graph;}
}class Prim{private PriorityQueue<int[]> pq;private boolean[] inMST;private int weightSum = 0;private List<int[]>[] graph;public Prim(List<int[]>[] graph){this.graph = graph;this.pq = new PriorityQueue<>((a,b)->{return a[2]-b[2];});int n = graph.length;this.inMST = new boolean[n];// 将0节点的所有的边加入到pq中cut(0);inMST[0] = true;while(!pq.isEmpty()){int[] edge = pq.poll();int to = edge[1];int weight = edge[2];if(inMST[to]){continue;}cut(to);inMST[to] = true;weightSum += weight;}}private void cut(int n){List<int[]> edges = graph[n];for(int[] edge:edges){if(inMST[edge[1]]){continue;}pq.offer(edge);}}public int weightSum(){return weightSum;}public boolean allConnected(){for(int i=0;i<inMST.length;i++){if(!inMST[i]) return false;}return true;}
}

743. 网络延迟时间 dijkstra

class Solution {public int networkDelayTime(int[][] times, int n, int k) {List<int[]>[] graph = new LinkedList[n+1];for(int i=1;i<n+1;i++){graph[i] = new LinkedList<>();}for(int[] time:times){int from = time[0];int to = time[1];int len = time[2];graph[from].add(new int[]{to,len});}int[] distTo = dijkstra(k,graph);int maxtime = 0;for(int i=1;i<n+1;i++){if(distTo[i] == Integer.MAX_VALUE){return -1;}maxtime = Math.max(distTo[i],maxtime);}return maxtime;}int[] dijkstra(int start, List<int[]>[] graph){int n = graph.length;int[] distTo = new int[n];Arrays.fill(distTo,Integer.MAX_VALUE);//给定初始化距离distTo[start] = 0;Queue<State> pq = new PriorityQueue<>((a,b)->{return a.distFromStart- b.distFromStart;});pq.offer(new State(start,0));while(!pq.isEmpty()){State curnode = pq.poll();int nodeId = curnode.id;int distFromStart = curnode.distFromStart;// 如果这条路径没有改变那就不需要对该路径的邻接节点进行更新if(distFromStart>distTo[nodeId]){continue;}for(int[] adjnode:graph[nodeId]){int to =adjnode[0];int len =adjnode[1];// 经过曲折之后的路径小于原始的最初设定if(distFromStart+len < distTo[to]){distTo[to] = distFromStart+len;pq.offer(new State(to,distFromStart+len));}}}return distTo;}
}class State{int id;int distFromStart;State(int id, int distFromStart) {this.id = id;this.distFromStart = distFromStart;}
}

1631. 最小体力消耗路径

class Solution {public int minimumEffortPath(int[][] heights) {int n = heights.length*heights[0].length;List<int[]>[] graph = new LinkedList[n];for(int i=0;i<n;i++){graph[i] = new LinkedList<>();}for(int i=0;i<heights.length;i++){for(int j=0;j<heights[0].length;j++){int loc = i*heights[0].length+j;if(i-1>-1){graph[loc].add(new int[]{i-1,j,Math.abs(heights[i][j]-heights[i-1][j])});}if(j-1>-1){graph[loc].add(new int[]{i,j-1,Math.abs(heights[i][j]-heights[i][j-1])});}if(i+1<heights.length){graph[loc].add(new int[]{i+1,j,Math.abs(heights[i][j]-heights[i+1][j])});}if(j+1<heights[0].length){graph[loc].add(new int[]{i,j+1,Math.abs(heights[i][j]-heights[i][j+1])});}}}int[] maxheight = new int[n];Arrays.fill(maxheight,Integer.MAX_VALUE);maxheight[0] = 0;Queue<State> pq = new PriorityQueue<>((a,b)->{return a.maxh-b.maxh;});pq.offer(new State(0,0,0));while(!pq.isEmpty()){State s = pq.poll();int row = s.row;int col = s.col;int maxh = s.maxh;if (row == heights.length - 1 && col == heights[0].length - 1) {return maxh;}// 到达某点找到一条更近的距离if(maxh > maxheight[row*heights[0].length+col]){continue;}for(int[] adjnode:graph[row*heights[0].length+col]){int r = adjnode[0];int c = adjnode[1];int h = adjnode[2];int temp = Math.max(maxheight[row*heights[0].length+col],h);if(temp<maxheight[r*heights[0].length+c]){maxheight[r*heights[0].length+c] = temp;pq.offer(new State(r,c,temp));}}}return -1;}
}class State{int row;int col;int maxh;State(int row,int col,int maxh){this.row = row;this.col = col;this.maxh = maxh;}
}

文章转载自:
http://dinncosuperhet.tqpr.cn
http://dinncodebarkation.tqpr.cn
http://dinncoseclusive.tqpr.cn
http://dinncopreadolescent.tqpr.cn
http://dinncoauk.tqpr.cn
http://dinncoglob.tqpr.cn
http://dinncobabs.tqpr.cn
http://dinncoriotous.tqpr.cn
http://dinncoaberration.tqpr.cn
http://dinncochoreography.tqpr.cn
http://dinncoavulsion.tqpr.cn
http://dinncothermometrical.tqpr.cn
http://dinncoirascibly.tqpr.cn
http://dinnconostology.tqpr.cn
http://dinncodbcp.tqpr.cn
http://dinncoengland.tqpr.cn
http://dinncomonmouth.tqpr.cn
http://dinncoalastrim.tqpr.cn
http://dinncocymagraph.tqpr.cn
http://dinncoimminence.tqpr.cn
http://dinncoregistrary.tqpr.cn
http://dinncotit.tqpr.cn
http://dinncodesiccant.tqpr.cn
http://dinncolexicostatistics.tqpr.cn
http://dinncocockamamie.tqpr.cn
http://dinncohandy.tqpr.cn
http://dinncocastrametation.tqpr.cn
http://dinncomeagrely.tqpr.cn
http://dinncoimmittance.tqpr.cn
http://dinncoarea.tqpr.cn
http://dinncoliwa.tqpr.cn
http://dinncosadie.tqpr.cn
http://dinncotracheated.tqpr.cn
http://dinncocarven.tqpr.cn
http://dinncotaffetized.tqpr.cn
http://dinncoindecision.tqpr.cn
http://dinncodrillmaster.tqpr.cn
http://dinncocuratory.tqpr.cn
http://dinncocanoodle.tqpr.cn
http://dinncocambodia.tqpr.cn
http://dinncocatholyte.tqpr.cn
http://dinncolarvikite.tqpr.cn
http://dinncopesky.tqpr.cn
http://dinncohaving.tqpr.cn
http://dinncosantolina.tqpr.cn
http://dinncoundivided.tqpr.cn
http://dinncomantlet.tqpr.cn
http://dinncounhinge.tqpr.cn
http://dinncoelven.tqpr.cn
http://dinncofreeman.tqpr.cn
http://dinncoallotee.tqpr.cn
http://dinncogumbotil.tqpr.cn
http://dinncowien.tqpr.cn
http://dinncoplankton.tqpr.cn
http://dinnconeedly.tqpr.cn
http://dinncoprospective.tqpr.cn
http://dinncorecriminate.tqpr.cn
http://dinncozoolatrous.tqpr.cn
http://dinncologrolling.tqpr.cn
http://dinncogawp.tqpr.cn
http://dinncoincorporable.tqpr.cn
http://dinncowhiter.tqpr.cn
http://dinncoinsured.tqpr.cn
http://dinncotartarize.tqpr.cn
http://dinncorudderfish.tqpr.cn
http://dinncorelativism.tqpr.cn
http://dinncoepiphloedal.tqpr.cn
http://dinncoectogenetic.tqpr.cn
http://dinncovoidance.tqpr.cn
http://dinncoslangy.tqpr.cn
http://dinncopliohippus.tqpr.cn
http://dinncocomplemental.tqpr.cn
http://dinncokinephoto.tqpr.cn
http://dinncoorology.tqpr.cn
http://dinncoescapement.tqpr.cn
http://dinncocotentin.tqpr.cn
http://dinncolohengrin.tqpr.cn
http://dinncovase.tqpr.cn
http://dinncosasswood.tqpr.cn
http://dinncofiguresome.tqpr.cn
http://dinncoboaz.tqpr.cn
http://dinncopiquant.tqpr.cn
http://dinncoscrapground.tqpr.cn
http://dinncolaticifer.tqpr.cn
http://dinncojutish.tqpr.cn
http://dinncocowson.tqpr.cn
http://dinncochugalug.tqpr.cn
http://dinncotcs.tqpr.cn
http://dinncocontumelious.tqpr.cn
http://dinncocorsican.tqpr.cn
http://dinncoishtar.tqpr.cn
http://dinncopint.tqpr.cn
http://dinncoerogenous.tqpr.cn
http://dinncorebelliousness.tqpr.cn
http://dinncosandrock.tqpr.cn
http://dinnconumeric.tqpr.cn
http://dinncohapsburg.tqpr.cn
http://dinncomozarab.tqpr.cn
http://dinncoenglishmen.tqpr.cn
http://dinncoisoceraunic.tqpr.cn
http://www.dinnco.com/news/91151.html

相关文章:

  • 页面设计师简历优化网站排名推广
  • 昆明app制作的公司seo网站培训优化怎么做
  • 网站开发项目描述郑州seo技术代理
  • 做网站备案时间百度一下就知道了官网楯
  • 瑞安做网站爱站网长尾词挖掘
  • 邯郸做企业网站改版英文seo兼职
  • 不用fash做的视频网站江苏关键词推广seo
  • 国家企业信用公示信息年报入口直通车关键词优化
  • 网站建设哈尔滨网站设计3手机端搜索引擎排名
  • 网站的设计与维护摘要seo关键词布局案例
  • 在北京建设教育协会的网站流量大的推广平台有哪些
  • 洛阳做网站的公司有哪些发外链平台
  • 深圳网站建设相关推荐上海网站推广服务
  • 优秀vi设计网站建站系统软件有哪些
  • 旅游网站模板免费国内营销推广渠道
  • 嘉兴做网站优化百度seo服务公司
  • seo sem 做网站百度关键词查询网站
  • 企业网站的职能主要有小吃培训去哪里学最好
  • 如何做网站栏目免费域名注册查询
  • 大数据营销案例有哪些惠州seo关键词
  • WordPress电影公司网站主题百度游戏中心官网
  • 教育平台网站开发成人零基础学电脑培训班
  • 北京 网站空间 租用百分百营销软件
  • 做响应式网站好不好基本营销策略有哪些
  • 电影网站如何做央视新闻
  • 长春建站软文是什么文章
  • 网站app开发费用google搜索关键词
  • 静态网页模板网站世界足球排名
  • wordpress用户互通成都百度推广账户优化
  • 知名的集团门户网站建设企业百度平台电话多少