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

恢复wordpress修订版本号seo关键词排名优化制作

恢复wordpress修订版本号,seo关键词排名优化制作,做网站的顶部图片,做java网站后台开发需要什么技能文章目录 前言A - Dijkstra Algorithm0x00 算法题目0x01 算法思路0x02 代码实现 B - 最长路0x00 算法题目0x01 算法思路0x02 代码实现 C - 二分图最大匹配0x00 算法题目0x01 算法思路0x02 代码实现 D - 搭配飞行员0x00 算法题目0x01 算法思路0x02 代码实现 E - The Perfect Sta…

在这里插入图片描述
在这里插入图片描述

文章目录

  • 前言
  • A - Dijkstra Algorithm
    • 0x00 算法题目
    • 0x01 算法思路
    • 0x02 代码实现
  • B - 最长路
    • 0x00 算法题目
    • 0x01 算法思路
    • 0x02 代码实现
  • C - 二分图最大匹配
    • 0x00 算法题目
    • 0x01 算法思路
    • 0x02 代码实现
  • D - 搭配飞行员
    • 0x00 算法题目
    • 0x01 算法思路
    • 0x02 代码实现
  • E - The Perfect Stall
    • 0x00 算法题目
    • 0x01 算法思路
    • 0x02 代码实现
  • F - Asteroids
    • 0x00 算法题目
    • 0x01 算法思路
    • 0x02 代码实现
  • G - Til the Cows Come Home
    • 0x00 算法题目
    • 0x01 算法思路
    • 0x02 代码实现
  • H - 拓扑排序
    • 0x00 算法题目
    • 0x01 算法思路
    • 0x02 代码实现
  • 总结


前言

最短路Dijkstra,spfa,图论二分图算法AYIT—ACM训练(模板版)
A — Dijkstra
B — spfa/Dijkstra
C — 二分图
D — 二分图
E — 二分图
F — 二分图
G — Dijkstra
H — Topsort


A - Dijkstra Algorithm

0x00 算法题目

在这里插入图片描述

0x01 算法思路

Dijkstra算法基础模板题

💬 模板演示:

int dijkstra()
{memset(dist,0x3f,sizeof dist);dist[1]=0;for(int i=0;i<n;i++){int t=-1;for(int j=1;j<=n;j++){if(!st[j] && (t==-1 || dist[t] > dist[j]))t=j;}st[t]=true;for(int j=1;j<=n;j++)dist[j]=min(dist[j],dist[t]+g[t][j]);}if(dist[n]==0x3f3f3f3f) return -1;return dist[n];}

0x02 代码实现

朴素版本Dijkstra:

💬 代码演示:

#include<iostream>
#include<cstring>
#include<algorithm>using namespace std;
const int N = 510;
int g[N][N];
bool st[N];
int dist[N];
int n,s,f;int dijkstra()
{memset(dist,0x3f,sizeof dist);dist[s]=0;for(int i=0;i<n;i++){int t=-1;for(int j=1;j<=n;j++)if(!st[j] && (t==-1 || dist[t] > dist[j]))t=j;st[t]=true;for(int j=1;j<=n;j++)dist[j]=min(dist[j],dist[t]+g[t][j]);}if(dist[f]==0x3f3f3f3f) return -1;return dist[f];
}int main()
{cin>>n>>s>>f;for(int i=1;i<=n;i++){for(int j=1;j<=n;j++){int x;cin>>x;if(x==-1) g[i][j]=0x3f3f3f3f;else g[i][j]=x;}}int t =dijkstra();cout<<t<<endl;return 0;
}

🚩 运行结果:
在这里插入图片描述
spfa算法:
💬 代码演示:

#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>using namespace std;
const int N=110,M=110*110;
int n,s,f;
bool st[N];
int h[N],w[M],ne[M],e[M],idx;
int dist[N];void add(int a,int b,int c)
{e[idx]=b,w[idx]=c,ne[idx]=h[a],h[a]=idx++;
}int spfa()
{memset(dist,0x3f,sizeof dist);dist[s]=0;queue<int> q;q.push(s);while(q.size()){int t = q.front();q.pop();st[t]=false;for(int i=h[t];i!=-1;i=ne[i]){int j=e[i];if(dist[j] > dist[t] + w[i]){dist[j]=dist[t]+w[i];if(!st[j]){q.push(j);st[j]=true;}}}}if(dist[f]==0x3f3f3f3f) return -1;else return dist[f];
}int main()
{cin>>n>>s>>f;memset(h,-1,sizeof h);for(int i=1;i<=n;i++){for(int j=1;j<=n;j++){int x;cin>>x;//if(x==-1) continue;if(x>0) add(i,j,x);}}cout<<spfa()<<endl;return 0;
}

🚩 运行结果:
在这里插入图片描述

B - 最长路

0x00 算法题目

在这里插入图片描述

0x01 算法思路

spfa算法基础模板题

💬 模板演示:

int spfa()
{memset(dist, 0x3f, sizeof dist);dist[1] = 0;queue<int> q;q.push(1);while(q.size()){auto t = q.front();q.pop();st[t]=false;for(int i=h[t];i!=-1;i=ne[i]){int j = e[i];if(dist[j] > dist[t]+w[i]){dist[j]=dist[t]+w[i];if(!st[j]){q.push(j);st[j]=true;}}}}return dist[n];
}

0x02 代码实现

spfa算法:
💬 代码演示:

#include<bits/stdc++.h>
#define endl '\n'using namespace std;
const int N = 1510,INF = 0x3f3f3f3f;
int n,m;
int dist[N];
int g[N][N];
queue<int> q;void spfa()
{memset(dist,-1,sizeof dist);dist[1]=0;q.push(1);while(!q.empty()){int t = q.front();q.pop();for(int j=1;j<=n;j++){if(g[t][j] && dist[j] < dist[t] + g[t][j]){dist[j] = dist[t] + g[t][j];q.push(j);}}}}int main()
{cin>>n>>m;for(int i=1;i<=m;i++){int a,b,c;cin>>a>>b>>c;g[a][b]=max(g[a][b],c);}spfa();cout<<dist[n]<<endl;return 0;
}

🚩 运行结果:
在这里插入图片描述

C - 二分图最大匹配

0x00 算法题目

在这里插入图片描述

0x01 算法思路

二分图模板题

💬 模板演示:

//邻接表
bool find(int x)
{for (int i = h[x]; i != -1; i = ne[i]){int j = e[i];if (!st[j]){st[j] = true;if (match[j] == 0 || find(match[j])){match[j] = x;return true;}}}return false;
}
//邻接矩阵
bool find(int x)
{for(int i=0;i<g[x].size();++i){int j = g[x][i];if(!st[j]){st[j]=true;if(match[j]==0 || find(match[j])){match[j]=x;return true;}}}return false;
}

0x02 代码实现

💬 代码演示:

#include<iostream>
#include<cstring>using namespace std;const int N = 510,M=5e4+10;
int n,m,q;
int h[N],e[M],ne[M],idx;
int match[N];
bool st[N];void add(int a,int b)
{e[idx]=b,ne[idx]=h[a],h[a]=idx++;
}bool find(int x)
{for(int i=h[x];i!=-1;i=ne[i]){int j = e[i];if(!st[j]){st[j]=true;if(match[j]==0 || find(match[j])){match[j]=x;return true;}}}return false;
}int main()
{cin>>n>>m>>q;memset(h,-1,sizeof h);while(q--){int u,v;cin>>u>>v;add(u,v);}int res=0;for(int i=1;i<=n;i++){memset(st,false,sizeof st);if(find(i)) res++;}cout<<res<<endl;return 0;
}

🚩 运行结果:
在这里插入图片描述

D - 搭配飞行员

0x00 算法题目

在这里插入图片描述

0x01 算法思路

二分图模板题

💬 模板演示:

//邻接表
bool find(int x)
{for (int i = h[x]; i != -1; i = ne[i]){int j = e[i];if (!st[j]){st[j] = true;if (match[j] == 0 || find(match[j])){match[j] = x;return true;}}}return false;
}
//邻接矩阵
bool find(int x)
{for(int i=0;i<g[x].size();++i){int j = g[x][i];if(!st[j]){st[j]=true;if(match[j]==0 || find(match[j])){match[j]=x;return true;}}}return false;
}

0x02 代码实现

💬 代码演示:

#include<iostream>
#include<cstring>
#include<algorithm>
#include<bits/stdc++.h>using namespace std;
const int N = 110;int n,m;
int map[N][N];
int match[N];
bool st[N];
vector<int> g[N];
bool find(int x)
{for(int i=0;i<g[x].size();++i){int j = g[x][i];if(!st[j]){st[j]=true;if(match[j]==0 || find(match[j])){match[j]=x;return true;}}}return false;
}int main()
{scanf("%d %d",&n,&m);int a,b;while(cin>>a>>b){g[a].push_back(b);}int res = 0;for(int i=1;i<=m;i++){memset(st,false,sizeof st);if(find(i)) {res++;}}cout<<res;return 0;
}

🚩 运行结果:
在这里插入图片描述

E - The Perfect Stall

0x00 算法题目

在这里插入图片描述

0x01 算法思路

二分图模板题

💬 模板演示:

//邻接表
bool find(int x)
{for (int i = h[x]; i != -1; i = ne[i]){int j = e[i];if (!st[j]){st[j] = true;if (match[j] == 0 || find(match[j])){match[j] = x;return true;}}}return false;
}
//邻接矩阵
bool find(int x)
{for(int i=0;i<g[x].size();++i){int j = g[x][i];if(!st[j]){st[j]=true;if(match[j]==0 || find(match[j])){match[j]=x;return true;}}}return false;
}

0x02 代码实现

💬 代码演示:

#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
const int N = 510,M=5e4+10;
int n,m;
int match[N];
bool st[N];
vector<int> g[N];bool find(int x)
{for(int i=0;i<g[x].size();++i){int j = g[x][i];if(!st[j]){st[j]=true;if(match[j]==0 || find(match[j])){match[j]=x;return true;}}}return false;
}int main()
{while(~scanf("%d%d",&n,&m)){memset(st,false,sizeof st);memset(match,0,sizeof match);for(int i=1;i<=n;i++){g[i].clear();int s;cin>>s;while(s--){int q;cin>>q;g[i].push_back(q);}}int res=0;for(int i=1;i<=n;i++){memset(st,false,sizeof st);if(find(i)) res++;}cout<<res<<endl;}return 0;
}

🚩 运行结果:
在这里插入图片描述

F - Asteroids

0x00 算法题目

在这里插入图片描述

0x01 算法思路

二分图模板题

💬 模板演示:

//邻接表
bool find(int x)
{for (int i = h[x]; i != -1; i = ne[i]){int j = e[i];if (!st[j]){st[j] = true;if (match[j] == 0 || find(match[j])){match[j] = x;return true;}}}return false;
}
//邻接矩阵
bool find(int x)
{for(int i=0;i<g[x].size();++i){int j = g[x][i];if(!st[j]){st[j]=true;if(match[j]==0 || find(match[j])){match[j]=x;return true;}}}return false;
}

0x02 代码实现

💬 代码演示:

#include<iostream>
#include<cstring>
using namespace std;
const int N = 510,M=5e4+10;
int n,m,q;
int h[N],e[M],ne[M],idx;
int match[N];
bool st[N];void add(int a,int b)
{e[idx]=b,ne[idx]=h[a],h[a]=idx++;
}bool find(int x)
{for(int i=h[x];i!=-1;i=ne[i]){int j = e[i];if(!st[j]){st[j]=true;if(match[j]==0 || find(match[j])){match[j]=x;return true;}}}return false;
}int main()
{cin>>n>>m;memset(h,-1,sizeof h);while(m--){int u,v;cin>>u>>v;add(u,v);}int res=0;for(int i=1;i<=n;i++){memset(st,false,sizeof st);if(find(i)) res++;}cout<<res<<endl;return 0;
}

🚩 运行结果:
在这里插入图片描述

G - Til the Cows Come Home

0x00 算法题目

在这里插入图片描述

0x01 算法思路

Dijkstra算法基础模板题

💬 模板演示:

int dijkstra()
{memset(dist,0x3f,sizeof dist);dist[1]=0;for(int i=0;i<n;i++){int t=-1;for(int j=1;j<=n;j++){if(!st[j] && (t==-1 || dist[t] > dist[j]))t=j;}st[t]=true;for(int j=1;j<=n;j++)dist[j]=min(dist[j],dist[t]+g[t][j]);}if(dist[n]==0x3f3f3f3f) return -1;return dist[n];}

0x02 代码实现

💬 代码演示:

#include<iostream>
#include<cstring>
#include<algorithm>
#include<stdbool.h>using namespace std;const int N=1010,inf = 0x3f3f3f3f;int n,m;
bool st[N];
int dist[N];
int g[N][N];int dijkstra()
{memset(dist,inf,sizeof(dist));dist[1]= 0;for(int i=1;i <= n;i++){int t=-1;for(int j=1;j<=n;j++)if(!st[j] && (t==-1 || dist[t] > dist[j]))t=j;st[t]=true;for(int j=1;j<=n;j++)dist[j]=min(dist[j],dist[t]+g[t][j]);}return dist[n];
}int main()
{cin>>m>>n;memset(g,inf,sizeof g);for(int i=0;i<m;++i){int a,b,c;cin>>a>>b>>c; g[a][b]=g[b][a]=min(g[a][b],c);}cout<< dijkstra() <<endl;return 0;
}

🚩 运行结果:
在这里插入图片描述

H - 拓扑排序

0x00 算法题目

在这里插入图片描述

0x01 算法思路

拓扑排序算法基础模板题

💬 模板演示:

bool topsort()
{int hh=0,tt=-1;for (int i = 1; i <= n; i ++ )if (!d[i])q[ ++ tt] = i;while(hh<=tt){int t = q[hh ++ ];for (int i = h[t]; i != -1; i = ne[i]){int j = e[i];if (-- d[j] == 0)q[ ++ tt] = j;}}return tt==n-1;
}

0x02 代码实现

💬 代码演示:

#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>using namespace std;const int N=100010;int n,m;
vector<int> v[N];
int size,d[N];
int ans[N];void topsort()
{priority_queue<int,vector<int>,greater<int> > q;for(int i=1;i<=n;i++)if(!d[i]) q.push(i);while(!q.empty()){int t = q.top();q.pop();ans[size++] = t;for(auto it : v[t]){d[it]--;if(!d[it]) q.push(it);}}
}int main()
{cin>>n>>m;for(int i=0;i<m;i++){int a,b;cin>>a>>b;v[a].push_back(b);d[b]++;}topsort();for(int i=0 ; i<size ;i++)cout<< 'v' << ans[i] <<' ';return 0;
}

🚩 运行结果:
在这里插入图片描述


总结

这次训练很明显涉及到了最短路Dijkstra,spfa,图论二分图算法,以及topsort算法,这次考的比较基础,但是让我意识到了,算法必须熟练记忆模板是很重要的。


文章转载自:
http://douce.c7497.cn
http://dolicapax.c7497.cn
http://dnp.c7497.cn
http://nonreward.c7497.cn
http://rocket.c7497.cn
http://deltiologist.c7497.cn
http://prc.c7497.cn
http://deltawinged.c7497.cn
http://strap.c7497.cn
http://dews.c7497.cn
http://foglight.c7497.cn
http://bae.c7497.cn
http://clubber.c7497.cn
http://desynchronize.c7497.cn
http://neurotransmitter.c7497.cn
http://sizeable.c7497.cn
http://faucalize.c7497.cn
http://alptop.c7497.cn
http://dynapolis.c7497.cn
http://synod.c7497.cn
http://beastie.c7497.cn
http://unrove.c7497.cn
http://busheler.c7497.cn
http://molokai.c7497.cn
http://parapodium.c7497.cn
http://indefectible.c7497.cn
http://gallnut.c7497.cn
http://hubris.c7497.cn
http://abidingly.c7497.cn
http://autofilter.c7497.cn
http://valerianic.c7497.cn
http://definiens.c7497.cn
http://angelical.c7497.cn
http://levier.c7497.cn
http://prim.c7497.cn
http://splenium.c7497.cn
http://fonda.c7497.cn
http://practicer.c7497.cn
http://looie.c7497.cn
http://anisocercal.c7497.cn
http://rachilla.c7497.cn
http://whorehouse.c7497.cn
http://vallum.c7497.cn
http://leishmanial.c7497.cn
http://tenderee.c7497.cn
http://fiftyfold.c7497.cn
http://combatant.c7497.cn
http://gorp.c7497.cn
http://cingalese.c7497.cn
http://outgrowth.c7497.cn
http://metrological.c7497.cn
http://teleconferencing.c7497.cn
http://copulae.c7497.cn
http://miscarry.c7497.cn
http://haj.c7497.cn
http://edomite.c7497.cn
http://astringent.c7497.cn
http://disciplinarian.c7497.cn
http://abdias.c7497.cn
http://hillsite.c7497.cn
http://supervoltage.c7497.cn
http://lepidopter.c7497.cn
http://mothering.c7497.cn
http://hypolithic.c7497.cn
http://mappable.c7497.cn
http://semicoma.c7497.cn
http://screak.c7497.cn
http://metaldehyde.c7497.cn
http://schmeisser.c7497.cn
http://gppm.c7497.cn
http://fulbe.c7497.cn
http://subsidy.c7497.cn
http://venation.c7497.cn
http://bowered.c7497.cn
http://pennyworth.c7497.cn
http://bluebonnet.c7497.cn
http://colorfast.c7497.cn
http://thioester.c7497.cn
http://pinole.c7497.cn
http://cliquy.c7497.cn
http://homophyly.c7497.cn
http://transparently.c7497.cn
http://plexiglass.c7497.cn
http://siblingship.c7497.cn
http://holdover.c7497.cn
http://lignum.c7497.cn
http://emplacement.c7497.cn
http://sardegna.c7497.cn
http://hondo.c7497.cn
http://leprous.c7497.cn
http://microtransmitter.c7497.cn
http://seattle.c7497.cn
http://khurta.c7497.cn
http://rubber.c7497.cn
http://headboard.c7497.cn
http://tallish.c7497.cn
http://backlash.c7497.cn
http://profanation.c7497.cn
http://cholestyramine.c7497.cn
http://reinvestment.c7497.cn
http://www.zhongyajixie.com/news/69973.html

相关文章:

  • 怎么用花生壳做网站重庆做优化的网络公司
  • wordpress插件安装目录下株洲seo排名
  • 界面网站的风格关键词seo排名怎么做的
  • 权重查询站长工具黄页网推广服务
  • 建筑工程行业网站建设方案北京口碑最好的it培训机构
  • 有什么好的网站做数学题吗百度提交网站入口网址
  • 有网站源码 怎么做网站建立网站的流程
  • 移动网站建设指南seo关键词词库
  • 个人网店和网站的区别智推教育seo课程
  • 做一个招聘信息的网站_用什么做网站的软件有友情链接的网站
  • wordpress前台可发表文章福州外包seo公司
  • dw可以做有后台的网站么?今天最新新闻国内大事件
  • 有域名如何建网站seo综合查询接口
  • 襄阳网站制作外链网盘下载
  • 淄博公司制作网站有哪些宁阳网站seo推广
  • 安徽省建设工程测试研究院网站网络推广费用高吗
  • 公司做网站让拍照备案设计网站的软件
  • 免费的微商城温州最好的seo
  • 建设网站要做的工作搜索网站排行
  • 专门做java项目的网站搜索引擎推广方式有哪些
  • 北京招聘网站排行济南优化哪家好
  • java做网站的详细流程谷歌关键词查询工具
  • 公安网站建设自查报告杭州百度首页排名
  • 宁波市节约型机关建设考试网站优化网站排名工具
  • 新余建站公司合肥网站快速优化排名
  • 宜阳县住房和城乡建设局网站品牌营销策划公司排名
  • 域名备案需要什么资料西安seo工作室
  • 美国做电商网站有哪些内容seo搜索优化服务
  • 设计一套企业网站设计报价软文推广多少钱
  • 常州seo收费网站关键字优化