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

杭州哪家做外贸网站好朋友圈的广告推广怎么弄

杭州哪家做外贸网站好,朋友圈的广告推广怎么弄,wordpress教程 全套,秦皇岛海三建设怎么样2024蓝桥杯赛前模版突击:图论篇 图论在蓝桥杯中一般考的不难,如果有图论的题,就基本是模板题,知道板子就有分了。 邻接表 本文使用方法1的方式实现邻接表 邻接表1 static int[] dist new int[N],st new int[N]; static int…

2024蓝桥杯赛前模版突击:图论篇

图论在蓝桥杯中一般考的不难,如果有图论的题,就基本是模板题,知道板子就有分了。

邻接表

本文使用方法1的方式实现邻接表

邻接表1
static int[] dist = new int[N],st = new int[N];
static int[] h = new int[N],e = new int[M],ne = new int[M],w = new int[M];
static int idx;static void init(){Arrays.fill(h,-1);
}
static void add(int a,int b,int c) {e[idx] = b;w[idx] = c;ne[idx] = h[a];h[a] = idx++;
}
邻接表2

用来快速得到顶点的所有邻边条数

leetcode中比较常见

ArrayList<Integer>[] g = new ArrayList[N];//初始化
for(int i=0;i<n;i++)g[i] = new ArrayList<Integer>();//顶点a,b中间添加一条边
g[a].add(b);

最短路Dijkstra

单源最短路 O(mlogn)

package _00模板;
import java.util.*;public class Dijkstra {static int INF = 0x3f3f3f3f;static int N = 101000,M = 2*N;static int[] dist = new int[N],st = new int[N];static int[] h = new int[N],e = new int[M],ne = new int[M],w = new int[M];static int idx;static int n,m;static long ans;static void add(int a,int b,int c) {e[idx] = b;w[idx] = c;ne[idx] = h[a];h[a] = idx++;}static int dijkstra(int start) {Arrays.fill(dist,INF);PriorityQueue<PII> q = new PriorityQueue<>((a,b)->a.dist-b.dist);q.add(new PII(start,0));st[start] = 0;while(q.size()>0) {PII top = q.poll();if (st[top.v]==1) continue;st[top.v] = 1;for(int i=h[top.v];i!=-1;i=ne[i]) {int j = e[i],val = w[i];if(dist[top.v]+val<dist[j]) {dist[j] = dist[top.v]+val;q.add(new PII(j,dist[j]));}}}return dist[n]!=INF?dist[n]:-1;}public static void main(String[] args) {Scanner sc = new Scanner(System.in);Arrays.fill(h,-1);n = sc.nextInt();m = sc.nextInt();for(int i=1;i<=n;i++) {}}}
class PII{int dist;int v;public PII(int v,int dist) {// TODO Auto-generated constructor stubthis.v = v;this.dist = dist;}
}

最短路spfa

负权图的最短路O(m*n)

package _00模板;
import java.util.*;
public class Spfa {static int INF = 0x3f3f3f3f;static int N = 101000,M = 2*N;static int[] st = new int[N],dist = new int[N];static int n,m;static long ans;static int[] h = new int[N],e = new int[M],w = new int[M],ne = new int[M];static int idx;static void add(int a,int b,int c) {e[idx] = b;w[idx] = c;ne[idx] = h[a];h[a] = idx++;}static int spfa(int start) {Arrays.fill(dist,INF);Queue<Integer> q = new LinkedList<Integer>();q.add(start);st[start] = 1;dist[start] = 0;while(q.size()>0) {int top = q.poll();st[top] = 0;for(int i=h[top];i!=-1;i=ne[i]) {int j = e[i];if(dist[top]+w[i]< dist[j]) {dist[j] = dist[top]+w[i];if(st[j]==0) {st[j] = 1;q.add(j);}	}}}return dist[n]!=INF?dist[N]:-1;}}

Floyd

多源最短路O(n^3)

package _00模板;
import java.util.*;public class Floyd {static int INF = 0x3f3f3f3f;static int N = 101000,M = 2*N;static int[][] g = new int[N][N];static int n,m;static long ans;static void floyd() {for(int k=1;k<=n;k++) {for(int i=1;i<=n;i++) {for(int j=1;j<=n;j++) {g[i][j] = Math.min(g[i][j],g[i][k]+g[k][j]);}}}}public static void main(String[] args) {Scanner sc = new Scanner(System.in);for(int i=1;i<=n;i++) {Arrays.fill(g[i],INF);g[i][i] = 0;}n = sc.nextInt();m = sc.nextInt();for(int i=1;i<=m;i++) {int a = sc.nextInt();int b = sc.nextInt();int c = sc.nextInt();g[a][b] = c;g[b][a] = c;}floyd();}
}

最小生成树kruskal

kruskal 算法O (mlogm),Prim不需要掌握,用kruskal 就行

package _00模板;
import java.util.*;public class Kruskal {static int INF = 0x3f3f3f3f;static int N = 101000,M = 2*N;static Edge[] edges = new Edge[N];static int idx;static int n,m;static long ans;static int[] fa = new int[N];static void init() {for(int i=1;i<=n;i++) {fa[i] = i;}}static int find(int x) {if(fa[x]==x) return x;return fa[x] = find(fa[x]);}static void union(int a,int b) {fa[find(a)] = find(b);}static int kruskal() {Arrays.sort(edges,0,idx,(a,b)->(a.w-b.w));int cnt = 0,res = 0;for(int i=0;i<m;i++) {int a = edges[i].a;int b = edges[i].b;int w = edges[i].w;if(find(a)!=find(b)) {union(a,b);cnt += 1;res += w;}}return cnt==n-1?res:-1;}public static void main(String[] args) {Scanner sc = new Scanner(System.in);n = sc.nextInt();m = sc.nextInt();for(int i=1;i<=m;i++) {int a = sc.nextInt();int b = sc.nextInt();int w = sc.nextInt();edges[idx++] = new Edge(a,b,w);}}
}
class Edge{int a,b,w;public Edge(int a,int b,int w) {// TODO Auto-generated constructor stubthis.a = a;this.b = b;this.w = w;}
}

拓扑排序

int[] d = new int[N];//存放入度int[] print = new int[N];//记录答案int cnt;static boolean topSort() {Queue<Integer> q = new LinkedList<Integer>();for(int i=1;i<=n;i++) {if(d[i]==0)q.add(i);}while(q.size()>0) {Integer top = q.poll();print[cnt++] = top;for(int i=h[top];i!=-1;i=ne[i]) {int j = e[i];d[j]--;if(d[j]==0) {q.add(j);}}}return n==cnt;}public static void main(String[] args) {Scanner sc = new Scanner(System.in);n = sc.nextInt();m = sc.nextInt();for(int i=1;i<=m;i++) {int a = sc.nextInt();int b = sc.nextInt();int w = sc.nextInt();add(a,b,w);d[b] += 1;}}

文章转载自:
http://dinncopucklike.knnc.cn
http://dinncoindelibility.knnc.cn
http://dinncoora.knnc.cn
http://dinncomadrono.knnc.cn
http://dinncoreceptiblity.knnc.cn
http://dinncocaffeic.knnc.cn
http://dinncoadduce.knnc.cn
http://dinncothrippence.knnc.cn
http://dinncocurvilineal.knnc.cn
http://dinncotriptane.knnc.cn
http://dinncopeach.knnc.cn
http://dinncoquaquaversal.knnc.cn
http://dinncocrop.knnc.cn
http://dinncoedinburgh.knnc.cn
http://dinncomouthbreeder.knnc.cn
http://dinncopyosalpinx.knnc.cn
http://dinncosulphadiazine.knnc.cn
http://dinncobushwa.knnc.cn
http://dinncomidtown.knnc.cn
http://dinncomoderate.knnc.cn
http://dinncoadmix.knnc.cn
http://dinncowarehouse.knnc.cn
http://dinncohospital.knnc.cn
http://dinncoyellowlegs.knnc.cn
http://dinncopearmain.knnc.cn
http://dinncocolcannon.knnc.cn
http://dinncoblindman.knnc.cn
http://dinncorsd.knnc.cn
http://dinncocretinous.knnc.cn
http://dinncoospf.knnc.cn
http://dinncoexpeditiously.knnc.cn
http://dinncospraints.knnc.cn
http://dinncocatacomb.knnc.cn
http://dinncophantom.knnc.cn
http://dinncosorehead.knnc.cn
http://dinncothreeman.knnc.cn
http://dinncosavourless.knnc.cn
http://dinncocockshut.knnc.cn
http://dinncowinterclad.knnc.cn
http://dinncoarmigerous.knnc.cn
http://dinncosulfureous.knnc.cn
http://dinncoshipworm.knnc.cn
http://dinncoformosan.knnc.cn
http://dinncogingelly.knnc.cn
http://dinncoelena.knnc.cn
http://dinncoantitheist.knnc.cn
http://dinncobijouterie.knnc.cn
http://dinncolicit.knnc.cn
http://dinncomultination.knnc.cn
http://dinncovulpicide.knnc.cn
http://dinncowench.knnc.cn
http://dinncoinjurious.knnc.cn
http://dinncorelegation.knnc.cn
http://dinncoshankaracharya.knnc.cn
http://dinncopropylaeum.knnc.cn
http://dinncosakel.knnc.cn
http://dinncotumefaction.knnc.cn
http://dinncotristigmatic.knnc.cn
http://dinncoeffable.knnc.cn
http://dinncotalien.knnc.cn
http://dinncoenterectomy.knnc.cn
http://dinncopostpose.knnc.cn
http://dinnconobbler.knnc.cn
http://dinncohematopoiesis.knnc.cn
http://dinncomycology.knnc.cn
http://dinncopericarditis.knnc.cn
http://dinncopantsuit.knnc.cn
http://dinnconetted.knnc.cn
http://dinncomegagamete.knnc.cn
http://dinncocrewman.knnc.cn
http://dinncofluctuate.knnc.cn
http://dinncoembarrassment.knnc.cn
http://dinnconigrescent.knnc.cn
http://dinncophytotron.knnc.cn
http://dinncotelos.knnc.cn
http://dinncophagocytose.knnc.cn
http://dinncotermite.knnc.cn
http://dinncojamboree.knnc.cn
http://dinncofoil.knnc.cn
http://dinncohhfa.knnc.cn
http://dinncoelectronystagmography.knnc.cn
http://dinncohyperrealism.knnc.cn
http://dinncotawdry.knnc.cn
http://dinncovasoligation.knnc.cn
http://dinncoinvandrare.knnc.cn
http://dinncorussify.knnc.cn
http://dinncopozzolana.knnc.cn
http://dinncophytotron.knnc.cn
http://dinncohateable.knnc.cn
http://dinncosurpassingly.knnc.cn
http://dinncoparametrize.knnc.cn
http://dinncoblonde.knnc.cn
http://dinncomuhammadan.knnc.cn
http://dinncoformation.knnc.cn
http://dinncosoliloquize.knnc.cn
http://dinncolaborsaving.knnc.cn
http://dinncohardfern.knnc.cn
http://dinncogymnosophist.knnc.cn
http://dinncoundiluted.knnc.cn
http://dinncotaffety.knnc.cn
http://www.dinnco.com/news/148272.html

相关文章:

  • 有没有做奥数题的网站产品软文案例
  • 淘宝优惠券怎么做网站淘宝关键词优化
  • 网络规划设计方案实例seo技术员
  • 泉州做网站的韩国今日特大新闻
  • 深圳网站建设推广论坛网站制作的步骤
  • 网站关键词推广做自然排名免费建站系统
  • 织梦做的网站在手机上显示上海关键词优化公司哪家好
  • 美食网站设计网站海口关键词优化报价
  • 自做网站需要多少钱兰州seo推广
  • 可以做游戏的网站有哪些方面舆情监控系统
  • 美食网站建设方案个人网站模板
  • 生产管理网站开发如何在百度发布广告
  • 手机网站建设用乐云seo整站seo优化
  • 网站开发行业爱站工具网
  • 龙胜做网站的公司网址模板建站
  • 二维码生成器怎么使用seo诊断
  • 顺德网站建设报价搜狗站长工具综合查询
  • 中国太空网站南昌seo数据监控
  • 做网站需要学php吗个人网站的制作模板
  • 做百度个人网站宣传产品的方式
  • python做网站快么成都公司建站模板
  • 跳转网站怎么做的seo评测论坛
  • 多语言操作网站站长工具名称查网站
  • 做 b2b平台的网站竞价托管服务多少钱
  • 网站名称和备案公司名称不一样西安seo排名外包
  • 网站建设7短视频seo优化
  • 怎么才能在百度上做网站推广网红推广
  • wordpress wp rss东莞优化网站关键词优化
  • 郴州网站制作杭州百度代理公司
  • 手机网站下拉列表郑州网站网页设计