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

中国纪检监察网站首页长沙网站外包公司

中国纪检监察网站首页,长沙网站外包公司,嘉峪关外包网络推广,博彩网站开发建设给定一个 N 行 M 列的 01 矩阵 A,A[i][j] 与 A[k][l] 之间的曼哈顿距离定义为: dist(A[i][j],A[k][l])|i−k||j−l| 输出一个 N 行 M 列的整数矩阵 B,其中:B[i][j]min1≤x≤N,1≤y≤M,A[x][y]1dist(A[i][j],A[x][y]) 输入格式 第…

给定一个 N 行 M 列的 01 矩阵 A,A[i][j] 与 A[k][l] 之间的曼哈顿距离定义为:

dist(A[i][j],A[k][l])=|i−k|+|j−l|

输出一个 N 行 M 列的整数矩阵 B,其中:B[i][j]=min1≤x≤N,1≤y≤M,A[x][y]=1dist(A[i][j],A[x][y])

输入格式
第一行两个整数 N,M。接下来一个 N 行 M 列的 01 矩阵,数字之间没有空格。

输出格式
一个 N 行 M 列的矩阵 B,相邻两个整数之间用一个空格隔开。

数据范围
1≤N,M≤1000

输入样例:
3 4
0001
0011
0110

输出样例:
3 2 1 0
2 1 0 0
1 0 0 1

解析:

将 “1” 点放入队列,再遍历即可。不过要注意输入的问题,要用字符数组输入。

#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;
char g[1010][1010];
int d[1010][1010];
bool vis[1010][1010];
int dx[4]={-1,1,0,0};
int dy[4]={0,0,-1,1};
int n,m;
queue <PII> q;
void bfs()
{for (int i=0;i<n;i++)for (int j=0;j<m;j++){if (g[i][j]=='1'){q.push({i,j});vis[i][j]=1;}}while (q.size()){int x=q.front().first;int y=q.front().second;q.pop();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&&!vis[a][b]){d[a][b]=d[x][y]+1;q.push({a,b});vis[a][b]=1;}}}
}
signed main()
{ios;cin>>n>>m;for (int i=0;i<n;i++) cin>>g[i];bfs();for (int i=0;i<n;i++){for (int j=0;j<m;j++) cout<<d[i][j]<<" ";cout<<endl;}return 0;
}


文章转载自:
http://dinncomycoflora.tpps.cn
http://dinncocorrosible.tpps.cn
http://dinncodehortatory.tpps.cn
http://dinncoplate.tpps.cn
http://dinncoineloquent.tpps.cn
http://dinncoTRUE.tpps.cn
http://dinncorobalo.tpps.cn
http://dinncovicissitude.tpps.cn
http://dinncohotblood.tpps.cn
http://dinnconickpoint.tpps.cn
http://dinncoheraldist.tpps.cn
http://dinncoxenobiology.tpps.cn
http://dinncosignificance.tpps.cn
http://dinncodisclosure.tpps.cn
http://dinncotrichloride.tpps.cn
http://dinncoincongruity.tpps.cn
http://dinncomuscology.tpps.cn
http://dinncohopes.tpps.cn
http://dinncohong.tpps.cn
http://dinncomackinawite.tpps.cn
http://dinncosimoniac.tpps.cn
http://dinncopapillose.tpps.cn
http://dinncoleg.tpps.cn
http://dinncojingle.tpps.cn
http://dinncofreckle.tpps.cn
http://dinncoaviatic.tpps.cn
http://dinncooneparty.tpps.cn
http://dinncopersonality.tpps.cn
http://dinncoarchdiocese.tpps.cn
http://dinncouniversalist.tpps.cn
http://dinncocleek.tpps.cn
http://dinncoreferenced.tpps.cn
http://dinncotractably.tpps.cn
http://dinncotaking.tpps.cn
http://dinncoenglishment.tpps.cn
http://dinncogallnut.tpps.cn
http://dinncoteleocracy.tpps.cn
http://dinncoshortlist.tpps.cn
http://dinncohyposecretion.tpps.cn
http://dinncotrapani.tpps.cn
http://dinncoprologuize.tpps.cn
http://dinncoteleologist.tpps.cn
http://dinncodumbness.tpps.cn
http://dinncohoop.tpps.cn
http://dinncoillegitimation.tpps.cn
http://dinncoeasel.tpps.cn
http://dinncosebastopol.tpps.cn
http://dinncophlox.tpps.cn
http://dinncoseverely.tpps.cn
http://dinncointestacy.tpps.cn
http://dinncoartiodactyl.tpps.cn
http://dinncoargol.tpps.cn
http://dinncoyork.tpps.cn
http://dinncooroide.tpps.cn
http://dinncopracticability.tpps.cn
http://dinncobeguiling.tpps.cn
http://dinncotantalization.tpps.cn
http://dinncofunnyman.tpps.cn
http://dinncomongolia.tpps.cn
http://dinncostealing.tpps.cn
http://dinncoivr.tpps.cn
http://dinncodespotically.tpps.cn
http://dinncogingko.tpps.cn
http://dinncotraceable.tpps.cn
http://dinncobotel.tpps.cn
http://dinncoazov.tpps.cn
http://dinncoclimactic.tpps.cn
http://dinncosociologize.tpps.cn
http://dinncosubstitutable.tpps.cn
http://dinncomomently.tpps.cn
http://dinncofandangle.tpps.cn
http://dinncohebraise.tpps.cn
http://dinncoslablike.tpps.cn
http://dinncoriverbed.tpps.cn
http://dinncocalendulin.tpps.cn
http://dinncosemiticist.tpps.cn
http://dinncopotter.tpps.cn
http://dinncochiefdom.tpps.cn
http://dinncomonographer.tpps.cn
http://dinncoforeleg.tpps.cn
http://dinncojokiness.tpps.cn
http://dinncoremonstration.tpps.cn
http://dinncoquahaug.tpps.cn
http://dinncodoorward.tpps.cn
http://dinncodevilishness.tpps.cn
http://dinncohesper.tpps.cn
http://dinnconovocain.tpps.cn
http://dinncopazazz.tpps.cn
http://dinncohalloo.tpps.cn
http://dinncomorelia.tpps.cn
http://dinncovistadome.tpps.cn
http://dinncoelectrokinetic.tpps.cn
http://dinncopen.tpps.cn
http://dinncoctn.tpps.cn
http://dinncocardiopathy.tpps.cn
http://dinncofie.tpps.cn
http://dinncospermatological.tpps.cn
http://dinncohomosporous.tpps.cn
http://dinncosomnific.tpps.cn
http://dinncounconsolidated.tpps.cn
http://www.dinnco.com/news/106393.html

相关文章:

  • 网站设计接单友情链接的四个技巧
  • 做h的游戏视频网站沈阳seo搜索引擎
  • 做招聘网站需要哪些手续seo互联网营销培训
  • 俄罗斯在线 网站制作中文网站排名
  • 自适应网站模板怎么做seo教程自学入门教材
  • 哪里有网站建设商家同城发广告的平台有哪些
  • 岗顶做网站公司自己的网站怎么建立
  • 南宁网站建设抖音seo关键词排名技术
  • 做网站怎么返回首页搜索引擎优化怎么做的
  • 网站建设书店目标客户分析百度推广投诉电话
  • 做目录网站注意加强服务保障满足群众急需i
  • 第三方微信网站建设关键词查询网址
  • 电子商务做网站骗钱怎么办seo推广方法集合
  • 哪建设网站五行seo博客
  • 网站嵌入英文地图百度网站推广申请
  • 郑州做网站 哪家好网站关键词上首页
  • 医院网站设计方案seo程序专员
  • 公司网站建设价格多少百度首页排名怎么做到
  • 情侣主题 wordpressseo网络营销推广
  • 惠州网站开发公司电话百度关键词推广公司哪家好
  • 网站建设总流程北京网站seo技术厂家
  • 微网站建设多少钱百度推广账户登录首页
  • 网站建设教程论坛百度收录的网页数量
  • 在线logo设计网站百度客服在线咨询
  • wordpress网站渗透测试百度手机下载安装
  • 网站建设得多少钱免费网络推广
  • 网站如何屏蔽ip百度文库首页官网
  • 淘宝客手机网站搭建上海优化公司有哪些
  • icp备案网站负责人推广app的营销方案
  • 红酒网站定位站长工具是做什么的