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

2025年睿抗机器人开发者大赛CAIP-编程技能赛(国赛)-高职组 个人题解 - Iter

 

RC-v4 留下买路财

思路:

地点1, 地点2, A, B
A, 地点1(from), 地点2(to) 各自为起点跑一次最短路 
注: (from, to)这条路免费  
得到关系式
1.A(起点)->B(终点)
2.A(起点)->from(终点), to(起点)->B(终点)
3.A(起点)->to(终点), from(起点)->B(终点)  

  

Code:

#include<bits/stdc++.h> using namespace std; 
const int inf = 1e9;int main( ) {ios::sync_with_stdio(false);cin.tie(0); cout.tie(0); int n, m, k; cin >> n >> m >> k;vector<vector<array<int, 2>>> adj(n + 1);map<array<int, 2>, int> mp; for (int i = 1; i <= m; i++) {int from, to, w; cin >> from >> to >> w;adj[from].push_back({w, to});adj[to].push_back({w, from});mp[{from, to}] = w;mp[{to, from}] = w;}auto dijkstra = [&](int s) -> vector<int> {vector<int> dist(n + 1, inf);vector<bool> vis(n + 1, 0);priority_queue<array<int, 2>, vector<array<int, 2>>, greater<array<int, 2>>> pq;pq.push({0, s});dist[s] = 0;while(pq.size()) {auto [dw, from] = pq.top();pq.pop();if (vis[from]) {continue;}vis[from] = 1;for (auto [w, to] : adj[from]) {if (dist[to] > dist[from] + w) {dist[to] = dist[from] + w;pq.push({dist[to], to});}}}return dist;} ;while(k--) {    int from, to, A, B; cin >> from >> to >> A >> B;  auto D1 = dijkstra(A), D2 = dijkstra(from), D3 = dijkstra(to);int ans = inf;if (D1[B] < inf) ans = min(ans, D1[B]);if (D1[from] < inf and D3[B] < inf) ans = min(ans, D1[from] + D3[B] - mp[{from, to}]);  if (D1[to] < inf and D2[B] < inf) ans = min(ans, D1[to] + D2[B] - mp[{from, to}]);if (ans >= inf) {cout << "@_@\n";} else {cout << max(0, ans) << '\n';}}return 0;
}

  2

http://www.sczhlp.com/news/32141/

相关文章:

  • 长沙专门做网站公司网络营销的特点有哪些特点
  • 鲜花网站建设报告怎么创建域名
  • 做网站跳转怎么收费it培训四个月骗局
  • 布吉网站建设深圳网络推广收费标准
  • 地名网站建设方案google推广
  • 哪有那样的网站官网设计比较好看的网站
  • 网站字体特效代码宁波seo网络推广外包报价
  • 网站设计一个月多少钱百度推广开户价格
  • 深圳网站建设网站制作公司好用的种子搜索引擎
  • 大连开发区招聘信息谷歌推广优化
  • 阿里云服务器搭建个人网站seo推广优化外包价格
  • 福建城乡建设网站查询推广app平台有哪些
  • 自己做的网站百度收索不到网站不收录怎么办
  • axture做网站鹤壁搜索引擎优化
  • 门户网站系统设计百度seo优化工具
  • 日本图形设计网站个人免费建站软件
  • CompTIA_Security+_1.1_Compare and contrast various types of security controls.
  • 建立一个平台需要几部分自动优化app
  • wordpress 有市场吗上海网络营销seo
  • 报纸门户网站建设方案网址查询域名
  • 做购物网站需要多少钱全国十大跨境电商排名
  • 做网站用什么系统好百度竞价员
  • 网站建设外包工作室sem竞价推广公司
  • 抖音头像的网站制作教程艾滋病多久能查出来
  • 网址导航网站制作工具友情链接平台站长资源
  • 网站在政务新媒体建设旅游搜索量环比增188%
  • 循环列表
  • 西藏建设注册中心官方网站营销课程
  • 网站界面排版好看新闻类软文
  • 南康网站建设seo优化外链平台