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

合肥网站建设5k5西安未央区今天出啥事了

合肥网站建设5k5,西安未央区今天出啥事了,盐城网站开发代理商,西安电子商务网站洛谷P2895&#xff1a;用BFS走出危险区域&#xff0c;危险区域存在时间&#xff0c;我们用ma记录最快变成危险区域的时间&#xff0c; 然后每次枚举时间1然后跟ma数组比较看能不能走&#xff0c;然后时间复杂度为O(305^2)。 #include<iostream> #include<cstring>…

洛谷P2895:用BFS走出危险区域,危险区域存在时间,我们用ma记录最快变成危险区域的时间, 然后每次枚举时间+1然后跟ma数组比较看能不能走,然后时间复杂度为O(305^2)。

#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
const int N = 50010;
int m, x, y, t;
typedef pair<int, int>PII;
int ma[305][305], ans[305][305];
bool v[305][305];
int dx[5] = {1, -1, 0, 0, 0},dy[5] = {0, 0, 1, -1, 0};
int change(int x){if(x == -1)return 99999;return x;
}
int main(){cin >> m;memset(ma, -1, sizeof(ma));while(m--){cin >> x >> y >> t;for(int i = 0; i < 5; i++){if(x + dx[i] >= 0 && y + dy[i] >= 0 && (ma[x + dx[i]][y + dy[i]] == -1 || ma[x + dx[i]][y + dy[i]] > t)){ma[x + dx[i]][y + dy[i]] = t;}}}queue<PII> q;q.push({0, 0});v[0][0] = true;while(q.size()){auto t = q.front();q.pop();int xd = t.first, yd = t.second;int s = ans[xd][yd] + 1;if(ma[xd][yd] == -1){cout << s - 1 << endl;return 0;}for(int i = 0; i < 4; i++){int xx = xd + dx[i], yy = yd + dy[i];if(xx >= 0 && yy >= 0 && s < change(ma[xx][yy]) && !v[xx][yy]){v[xx][yy] = true;ans[xx][yy] = s;q.push({xx, yy});}}}cout << -1 << endl;return 0;
}

洛谷P2036

#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int n, ss = 1, bb;
int s[15], b[15];
bool flag[15];
int ans = 0x7ffffff;
void dfs(int x){if(x > n){}else{for(int i = 1; i <= n; i++){if(flag[i] == false){ss *= s[i], bb += b[i];flag[i] = true;ans = min(ans, abs(ss - bb));dfs(x + 1);ss /= s[i], bb -= b[i];flag[i] = false;}}}
}
int main(){cin >> n;for(int i = 1; i <= n; i++){cin >> s[i] >> b[i];}dfs(1);cout << ans << endl;return 0;
}

洛谷P1605迷宫

#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
int n, m, t;
const int N = 15;
int sx, sy, fx, fy, xd, yd;
bool za[N][N], st[N][N];
int ans;
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
void dfs(int x, int y){if(x == fx && y == fy){ans++;return;}for(int i = 0; i < 4; i++){int xx = x + dx[i], yy = y + dy[i];if(xx >= 1 && xx <= n && yy >= 1 && yy <= m && !za[xx][yy] && !st[xx][yy]){st[xx][yy] = true;dfs(xx, yy);st[xx][yy] = false;}}
}
int main(){cin >> n >> m >> t;cin >> sx >> sy >> fx >> fy;st[sx][sy] = true;//注意特殊点 while(t--){cin >> xd >> yd;za[xd][yd] = true;}dfs(sx, sy);cout << ans << endl;return 0;
}

http://www.dtcms.com/wzjs/613581.html

相关文章:

  • 如何让网站打不开 解析wordpress怎么修改导航栏
  • 廊坊网站建设公司哪家好做网站谈单
  • 拍卖 网站 建设阳春网站开发
  • 上海opencart网站建设有没有可以做游戏的网站吗
  • dw做的网站要多大做网站分几个步骤
  • 福田企业建站推广服务公司深圳网站备案拍照点
  • a做片手机免费网站域名ip查询
  • 婚纱网站html模板新区seo整站优化公司
  • 国内优秀设计网站推荐公司宣传片拍摄脚本
  • 资源优化排名网站我公司要网站建设
  • 现在网站开发和软件开发七台河新闻在线直播
  • 娱乐网站代理商怎么做网站开发主要内容和要求
  • 黔东南建设厅官方网站最火的自媒体平台排名
  • 网站建设課程wordpress汉化版
  • wordpress新建网站后台无法登陆电视直播网站建设
  • 怎么做个手机版的网站吗免费生成网页的网站
  • 医院网站建设需求分析wordpress 安装ssl
  • 怎么创建卡密网站动画设计图
  • 北京平台网站建设多少钱厦门网站建设服务
  • 海外酒店网站建设逻辑网络设计的目标是什么?
  • 给朋友做的相册网站没有了个人网站推广怎么做
  • 网站设计网站设计公司价格品牌网络营销推广
  • 设计自学网站哪个好网站制作公司怎样帮客户做优化
  • 三合一网站怎么建立网站设计ui
  • 驻马店网站网站建设网站权重如何做
  • 网站内外链接怎么做个人博客系统wordpress
  • 无锡响应式网站建设苏州网站设计哪家公司好
  • 永兴房产网站付费的网站推广该怎么做
  • 网站做的支付宝接口吗网站添加在线qq聊天
  • wordpress ask me网站seo置顶 乐云践新专家