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

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

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

    #include<bits/stdc++.h> using namespace std; struct node{ long long s,e; }a[110000]; long long n,m,b[110000],t[110000]; queue<node>q; void f(int start){ for(int i=1;i<=m;i++){ if(a[i].sstart) { q.push(a[i]); } } } int main(){ scanf("%d%d",&n,&m); for(int i=1;i<=m;i++){ int f,t; scanf("%d%d",&f,&t); a[i].s=f; a[i].e=t; } int st,en; scanf("%d%d",&st,&en); f(st); while(!q.empty()){ node head=q.front(); if(head.sen){ printf("%d",t[head.s]); return 0; } if(b[head.e]==0){ f(head.e); b[head.e]=1; t[head.e]=t[head.s]+1; } q.pop(); } printf("-1"); return 0; }

    userId_undefined

    Em0ty

    倔强青铜
    20阅读
    2回复
    2点赞
  • 题解

    userId_undefined

    法兰西玫瑰

    倔强青铜
    32阅读
    0回复
    1点赞
  • bfs + 邻接矩阵

    userId_undefined

    回来看看

    倔强青铜
    11阅读
    0回复
    0点赞
  • 题解

    呵呵哈哈

    userId_undefined

    复仇者_帅童

    尊贵铂金
    9阅读
    0回复
    0点赞
首页