当前位置:网站首页>[day3] reconstruction of roads
[day3] reconstruction of roads
2022-07-26 17:51:00 【SSL_ GYX】
Reconstruction of roads

Their thinking
b f s bfs bfs , Damaged road negative edge right , Undamaged 0 0 0 .( Even heard d f s dfs dfs Can run )
code
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,m,d;
int st,ed;
int v[110];
int f[100010];
int minn[110];
int a[110][110];
int flg[110][110];
void bfs()
{
f[1]=st;
memset(minn,0x3f3f3f3f,sizeof(minn));
minn[st]=0;
int hd=0,tl=1;
while(hd<tl)
{
hd++;
int x=f[hd];
for(int i=1;i<=n;i++)
{
if(minn[x]+a[x][i]<minn[i])
{
minn[i]=minn[x]+a[x][i];
if(!v[i])
v[i]=1,f[++tl]=i;
}
}
v[x]=0;
}
}
int main()
{
freopen("road.in","r",stdin);
freopen("road.out","w",stdout);
cin>>n>>m;
memset(a,0x3f3f3f3f,sizeof(a));
for(int i=1;i<=m;i++)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
a[x][y]=a[y][x]=z;
}
cin>>d;
for(int i=1;i<=d;i++)
{
int x,y;
scanf("%d%d",&x,&y);
flg[x][y]=flg[y][x]=1;
}
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
if(!flg[i][j]&&a[i][j]!=0x3f3f3f3f)
a[i][j]=0;
cin>>st>>ed;
bfs();
cout<<minn[ed]<<endl;
}
边栏推荐
- [300 opencv routines] 240. Shi Tomas corner detection in opencv
- 来吧开发者!不只为了 20 万奖金,试试用最好的“积木”来一场头脑风暴吧!...
- Analysis of interface testing
- 第16周OJ实践1 计算该日在本年中是第几天
- Spark data format unsafe row
- Several ways to resolve hash conflicts
- ACL experiment demonstration (Huawei router device configuration)
- RedisDesktopManager去除升级提示
- uni-app
- How to become a better data scientist by learning to ask questions
猜你喜欢

ASEMI整流桥KBPC3510,KBPC3510封装,KBPC3510应用

Deep learning experiment: softmax realizes handwritten digit recognition

【集训Day1】Spy dispatch

Heavy! The 2022 China open source development blue book was officially released

Redisdesktopmanager removes the upgrade prompt

AI zhetianchuan ml integrated learning

(24) the top menu of blender source code analysis shows code analysis

Week 17 free intrusion pointer exercise - output maximum

解决哈希冲突的几种方式

(25)Blender源码分析之顶层菜单Blender菜单
随机推荐
JS recursive Fibonacci sequence deep cloning
# MySQL 七种连接方式图解
Ascend目标检测与识别-定制自己的AI应用
敏捷开发与DevOps的对比
(24)Blender源码分析之顶层菜单显示代码分析
Brief introduction to CUDA image construction
Leetcode:1206. design jump table [jump table board]
Sign up now | oar hacker marathon phase III midsummer debut, waiting for you to challenge
【元宇宙欧米说】剖析 Web3 风险挑战,构筑 Web3 生态安全
ACL experiment demonstration (Huawei router device configuration)
如何通过学会提问,成为更加优秀的数据科学家
AI遮天传 ML-无监督学习
Familiarize you with the "phone book" of cloud network: DNS
AI遮天传 DL-多层感知机
跨站点请求伪造(CSRF)
来吧开发者!不只为了 20 万奖金,试试用最好的“积木”来一场头脑风暴吧!
The chess robot broke the finger of a 7-year-old boy because "the chess player violated safety rules"?
kaggle猫狗数据集开源——用于经典CNN分类实战
Spark数据格式UnsafeRow
Come on developer! Not only for the 200000 bonus, try the best "building blocks" for a brainstorming!