acgo题库
  • 首页
  • 题库
  • 题单
  • 竞赛
  • 讨论
  • 排行
  • 团队
  • 备赛专区

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
登录
注册
题目详情题解(0)讨论(0)提交记录(0)
  • AC了

    userId_undefined

    小桂子GUINEVERE

    荣耀黄金
    52阅读
    0回复
    0点赞
  • 49

    #include <bits/stdc++.h> using namespace std; struct node{ int from,to,len; }x[20005]; int dis[2005],vis[2005],n,l=0; int main(){ cin>>n; while(true){ int a,b,c; cin>>a>>b>>c; if(a==0) break; x[l].from = a; x[l].to = b; x[l].len = c; l++; } dis[1] = 1e9; queue<int>q; vis[1] = 1; q.push(1); while(!q.empty()){ int f = q.front(); vis[f] = 0; q.pop(); for(int i = 0;i<l;i++){ int from = x[i].from,to = x[i].to,len = x[i].len; if(dis[to]<min(dis[from],len)){ dis[to]=min(dis[from],len); if(!vis[to]){ q.push(to); vis[to] = 1; } } } } for(int i = 2; i <= n; i ++){ cout<<dis[i]<<endl; } return 0; }

    userId_undefined

    我

    倔强青铜
    2阅读
    0回复
    0点赞
首页