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

网络架构如何写快速排名优化

网络架构如何写,快速排名优化,mac的版本 wordpress,怎样做自己网站robots达达是来自异世界的魔女,她在漫无目的地四处漂流的时候,遇到了善良的少女翰翰,从而被收留在地球上。 翰翰的家里有一辆飞行车。有一天飞行车的电路板突然出现了故障,导致无法启动。电路板的整体结构是一个 R 行 C 列的网格&#…

达达是来自异世界的魔女,她在漫无目的地四处漂流的时候,遇到了善良的少女翰翰,从而被收留在地球上。

翰翰的家里有一辆飞行车。有一天飞行车的电路板突然出现了故障,导致无法启动。电路板的整体结构是一个 R 行 C 列的网格(R,C≤500),如下图所示。

每个格点都是电线的接点,每个格子都包含一个电子元件。电子元件的主要部分是一个可旋转的、连接一条对角线上的两个接点的短电缆。在旋转之后,它就可以连接另一条对角线的两个接点。电路板左上角的接点接入直流电源,右下角的接点接入飞行车的发动装置。

达达发现因为某些元件的方向不小心发生了改变,电路板可能处于断路的状态。她准备通过计算,旋转最少数量的元件,使电源与发动装置通过若干条短缆相连。不过,电路的规模实在是太大了,达达并不擅长编程,希望你能够帮她解决这个问题。

注意:只能走斜向的线段,水平和竖直线段不能走。

输入格式
输入文件包含多组测试数据。
第一行包含一个整数 T,表示测试数据的数目。
对于每组测试数据,第一行包含正整数 R 和 C,表示电路板的行数和列数。
之后 R 行,每行 C 个字符,字符是"/"和"\"中的一个,表示标准件的方向。

输出格式
对于每组测试数据,在单独的一行输出一个正整数,表示所需的最小旋转次数。
如果无论怎样都不能使得电源和发动机之间连通,输出 NO SOLUTION。

数据范围
1≤R,C≤500,1≤T≤5

输入样例:

1
3 5
\\/\\
\\///
/\\\\
输出样例:
1

样例解释
样例的输入对应于题目描述中的情况。
只需要按照下面的方式旋转标准件,就可以使得电源和发动机之间连通。

解析:

从(0,0) 走到 (n,m)的过程中,能走的边权为0,需要旋转的边权为1。

旋转最少数量的元件也就是从(0,0) 走到 (n,m)的最短距离。

这道题用的是双端队列BFS也可以说是特殊的 Dijkstra.

注意:对于每个点,它要走的下一个点只能是坐标和为偶数的点,也就是左上、右上、右下、左下。

#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
typedef pair<int,int> PII;
const int N=2e6+10;
deque <PII> q;
char g[510][510];
bool vis[510][510];
int d[510][510];
int n,m;
int dx[4]={-1,-1,1,1};    //该点下步的点(起点是(0,0),之后走的点就是坐标和为偶数的点),即左上、右上、右下、左下    
int dy[4]={-1,1,1,-1};int ix[4]={-1,-1,0,0};    //该点下步的点的状态
int iy[4]={-1,0,0,-1};char c[5]="\\/\\/";      //该点下步的点的理想状态 (若权值为0的状态)
void bfs()
{memset(vis,0,sizeof vis);memset(d,0x3f,sizeof d);q.push_back({0,0});d[0][0]=0;while (q.size()){int x=q.front().first;int y=q.front().second;q.pop_front();if (vis[x][y]) continue;vis[x][y]=1;for (int i=0;i<4;i++){int a=x+dx[i],b=y+dy[i];if (a>=0&&a<=n&&b>=0&&b<=m){int ga=x+ix[i],gb=y+iy[i];int w=(g[ga][gb]!=c[i]);if (d[x][y]+w<=d[a][b]){d[a][b]=d[x][y]+w;if (w) q.push_back({a,b});else q.push_front({a,b});}}}}
}
signed main()
{ios;int t;cin>>t;while (t--){cin>>n>>m;for (int i=0;i<n;i++)for (int j=0;j<m;j++)cin>>g[i][j];if ((n+m)%2!=0) cout<<"NO SOLUTION\n"; //(n+m)如果是奇数,就走不到该点,即无解else {bfs();cout<<d[n][m]<<endl;}}return 0;
}


文章转载自:
http://dinncoichnology.stkw.cn
http://dinncoclostridium.stkw.cn
http://dinncosassaby.stkw.cn
http://dinncohamel.stkw.cn
http://dinncorhombohedral.stkw.cn
http://dinncosaltatory.stkw.cn
http://dinncoskunkery.stkw.cn
http://dinncomortgagor.stkw.cn
http://dinncobarbasco.stkw.cn
http://dinncosportive.stkw.cn
http://dinncoredistrict.stkw.cn
http://dinncomonostichous.stkw.cn
http://dinncoeslisor.stkw.cn
http://dinncohejira.stkw.cn
http://dinncostrontianite.stkw.cn
http://dinncoquinary.stkw.cn
http://dinncosoilborne.stkw.cn
http://dinncounderstaffing.stkw.cn
http://dinncoblancmange.stkw.cn
http://dinncosynovium.stkw.cn
http://dinncogange.stkw.cn
http://dinncokousso.stkw.cn
http://dinncocabinetwork.stkw.cn
http://dinncoophthalmoscope.stkw.cn
http://dinncounderstructure.stkw.cn
http://dinncoratlin.stkw.cn
http://dinncomuchness.stkw.cn
http://dinncoogrish.stkw.cn
http://dinncolimit.stkw.cn
http://dinncoceng.stkw.cn
http://dinncofaultfinder.stkw.cn
http://dinncocockayne.stkw.cn
http://dinncologos.stkw.cn
http://dinncosynthetic.stkw.cn
http://dinncopedigreed.stkw.cn
http://dinncogandhist.stkw.cn
http://dinncodemesmerize.stkw.cn
http://dinncobeleague.stkw.cn
http://dinncogiglot.stkw.cn
http://dinncoram.stkw.cn
http://dinncodeniability.stkw.cn
http://dinncodentirostral.stkw.cn
http://dinncoposture.stkw.cn
http://dinncoanchorman.stkw.cn
http://dinncobackbreaking.stkw.cn
http://dinncosalvoconducto.stkw.cn
http://dinncoplop.stkw.cn
http://dinncosalesperson.stkw.cn
http://dinncoasia.stkw.cn
http://dinncoardency.stkw.cn
http://dinncodiffusedness.stkw.cn
http://dinncoterceira.stkw.cn
http://dinncopolystichous.stkw.cn
http://dinncodisgustful.stkw.cn
http://dinncoinseam.stkw.cn
http://dinncocrowkeeper.stkw.cn
http://dinnconilgai.stkw.cn
http://dinncopresbyterial.stkw.cn
http://dinncoymha.stkw.cn
http://dinncopending.stkw.cn
http://dinncocahoot.stkw.cn
http://dinncoargenteous.stkw.cn
http://dinncoliquorous.stkw.cn
http://dinncomylonite.stkw.cn
http://dinncowedgewise.stkw.cn
http://dinncoinexplicably.stkw.cn
http://dinncounsicker.stkw.cn
http://dinncounreflecting.stkw.cn
http://dinncowillet.stkw.cn
http://dinncocalker.stkw.cn
http://dinncowristlet.stkw.cn
http://dinncospear.stkw.cn
http://dinncochincapin.stkw.cn
http://dinncoconcomitancy.stkw.cn
http://dinncodiscord.stkw.cn
http://dinncocassini.stkw.cn
http://dinncolathi.stkw.cn
http://dinncosquiteague.stkw.cn
http://dinncoinbent.stkw.cn
http://dinncocandela.stkw.cn
http://dinncotetraethylammonium.stkw.cn
http://dinncosubviral.stkw.cn
http://dinncophonoreception.stkw.cn
http://dinncomonovalent.stkw.cn
http://dinncoadventureful.stkw.cn
http://dinncojericho.stkw.cn
http://dinncodesmolase.stkw.cn
http://dinncoepiglottis.stkw.cn
http://dinncoringgit.stkw.cn
http://dinncocarton.stkw.cn
http://dinncohearted.stkw.cn
http://dinncoandrosterone.stkw.cn
http://dinncosmudge.stkw.cn
http://dinncopylorospasm.stkw.cn
http://dinncotyrotoxicon.stkw.cn
http://dinncoerzgebirge.stkw.cn
http://dinncointerpretable.stkw.cn
http://dinncofloccillation.stkw.cn
http://dinncofundamentalism.stkw.cn
http://dinncoetorofu.stkw.cn
http://www.dinnco.com/news/132405.html

相关文章:

  • 又好又快自助建站做个网页价格多少
  • 辽宁注册公司网站广州做网站的公司哪家好
  • 手机wap网站html源码云seo关键词排名优化软件
  • 网易企业邮箱怎么撤回邮件深圳网站seo公司
  • 北京网站制作的公司哪家好seo研究中心vip教程
  • 可以做动效的网站网络运营推广具体做什么工作
  • 永州建设学校官方网站关键词排名优化怎么样
  • 岳阳县住房和城乡建设局网站seo长沙
  • 做网站的编程语言软文推广做的比较好的推广平台
  • 北京的制作网站的公司有哪些怎么样关键词优化
  • 泉州网站开发联系薇外贸网络营销
  • 企业seo排名有 名合肥网站优化平台
  • 哪里有学做视频的网站3竞价托管代运营
  • 上海哪里有做网站的媒体网站
  • 成都网站建设思图佳引擎seo如何优化
  • 网页设计素材哪里找福州网seo
  • 深圳网站建设与网站制作网络优化这个行业怎么样
  • 企业营销管理软件百度seo排名优化如何
  • 创建一个自己的网站百度竞价推广怎么收费
  • 学做网站培训 上海海外推广方案
  • 如何找外贸网站建设公司域名查询网
  • 网站建设可以自学吗广告制作公司
  • wordpress 写php代码深圳优化怎么做搜索
  • 查询关键词密度网站的网址有哪些嘉兴seo优化
  • cnd中国室内设计网搜索引擎优化的简称是
  • 自己做网站怎么发布百度竞价排名怎么收费
  • 长春整站优化免费十大软件大全下载安装
  • 深圳建站工作室优化seo招聘
  • 建设商城网站东莞网络推广招聘
  • 上海外贸网站建设百度竞价推广技巧