文章

2

粉丝

0

获赞

2

访问

37

头像
二叉树的最短路径长度 题解:使用数组和队列,数组存树,队列存储含有值的结点下标,依次插入
P1654 北京邮电大学机试题
发布于2026年3月16日 14:54
阅读数 10

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    while(cin>>t)
    {
        while(t--)
        {
            int n,m;
            cin>>n>>m;
            vector<int> t(10000,-1);
            queue<int> q;
            t[1]=1;
            q.push(1);
            while(n--)
            {
                int a,b,i=q.front();
                cin>>a>>b;
                q.pop();
                if(a!=-1)
         ...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发