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

规划排版网站seo技术助理

规划排版网站,seo技术助理,现在网站尺寸,网站建站流程在原本基本的数船的基础上,增加了船不能畸形的要求,船只能是矩形,由此需要在dfs找船前确定是否有畸形船 .* ** *. ** ** .* ** *. 出现畸形船的情况如上图,即两艘船有一个交集时,此时就可以判断出bad pl…

在原本基本的数船的基础上,增加了船不能畸形的要求,船只能是矩形,由此需要在dfs找船前确定是否有畸形船

.*   **   *.   **
**   .*   **   *.

出现畸形船的情况如上图,即两艘船有一个交集时,此时就可以判断出bad placement

#include <stdio.h>
#include<stdlib.h>
#include<string.h>
#define max 1005
int r,c;
char ship[max][max];
int count=0;
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int row,line;
void dfs(int x,int y){ship[x][y]='.';for(int i=0;i<4;i++){row=x+dx[i];line=y+dy[i];if(row>=1&&row<=r&&line>=1&&line<=c&&ship[row][line]=='#'){dfs(row,line);}}
}
int main() {scanf("%d %d",&r,&c);for(int i=1;i<=r;i++){for(int j=1;j<=c;j++){scanf(" %c",&ship[i][j]);}}for(int i=1;i<r;i++){for(int j=1;j<c;j++){int cnt=0;if(ship[i][j]=='#') cnt++;if(ship[i+1][j]=='#') cnt++;if(ship[i][j+1]=='#') cnt++;if(ship[i+1][j+1]=='#') cnt++;if(cnt==3){//此时为相撞的情况printf("Bad placement.");return 0;}}}for(int i=1;i<=r;i++){for(int j=1;j<=c;j++){if(ship[i][j]=='#'){dfs(i,j);count++;}}}printf("There are %d ships.",count);return 0;
}

就当熟悉了bfs的函数

#include <stdio.h>
#include<stdlib.h>
#include<string.h>
#define max 1005
typedef struct{int x,y,step;
}Node;
Node queue[max*max];//数组模拟队列
int n;
int fx,fy,ex,ey;
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
char g[max][max];
int head=0,tail=0;
void bfs(){queue[tail++]=(Node){fx,fy,0};g[fx][fy]='1';while(head<tail){//队列不为空Node cur=queue[head++];if(cur.x==ex&&cur.y==ey){printf("%d\n",cur.step);return;}for(int i=0;i<4;i++){int row=cur.x+dx[i];int line=cur.y+dy[i];if(row>=1&&row<=n&&line>=1&&line<=n&&g[row][line]=='0'){queue[tail++]=(Node){row,line,cur.step+1};g[row][line]='1';}}}
}
int main() {scanf("%d",&n);for(int i=1;i<=n;i++){for(int j=1;j<=n;j++){scanf(" %c",&g[i][j]);}}scanf("%d %d %d %d",&fx,&fy,&ex,&ey);bfs();return 0;
}

http://www.hkea.cn/news/759503/

相关文章:

  • 湖南手机版建站系统哪个好百度网盘app怎么打开链接
  • asp网站开发的实训报告电商营销推广有哪些?
  • 交互设计流程外贸网站优化公司
  • 网络营销网站策划个人网站seo入门
  • 云南省网站备案要求全渠道营销的概念
  • 装修网站合作平台有哪些torrentkitty磁力猫
  • 大理网站开发长春seo结算
  • 西双版纳疫情最新情况seo营销的概念
  • 网站推广seo蜘蛛屯优化排名模板建网站价格
  • 怎样建设公司网站小程序b2b网站大全免费
  • 百度抓取不到网站百度识图搜索图片来源
  • 企业网站栏目规划的重要性网络营销的概述
  • 公司网站建设找谁做免费发布推广信息网站
  • 虚拟币网站开发seo百度关键字优化
  • 网站建设都 包括哪些淄博网站制作
  • 自己做装修网站南宁百度推广seo
  • 品牌建设浅谈seo网络营销外包
  • 昆山网站建设兼职千锋教育的官网
  • cm域名做网站盘古百晋广告营销是干嘛
  • 网站栏目策划企业网络营销方案
  • 网站自动采集指标sem广告投放是做什么的
  • 想做一个个人网站怎么做培训学校
  • 网站开发ipv6升级如何创建自己的小程序
  • 做网站需要备案吗外贸网站推广与优化
  • 独立网站建设流程b站视频推广网站动漫
  • 泰安诚信的网站建设b站推广入口2023年
  • 高校网站建设资料库东莞seo推广公司
  • 电子印章手机在线制作软件四川seo整站优化费用
  • 个人风采网站制作外贸网站平台哪个好
  • 沈阳企业建站谷歌推广和seo