2367:Genealogical tree

描述
The system of Martians' blood relations is confusing enough. Actually, Martians bud when they want and where they want. They gather together in different groups, so that a Martian can have one parent as well as ten. Nobody will be surprised by a hundred of children. Martians have got used to this and their style of life seems to them natural.
And in the Planetary Council the confusing genealogical system leads to some embarrassment. There meet the worthiest of Martians, and therefore in order to offend nobody in all of the discussions it is used first to give the floor to the old Martians, than to the younger ones and only than to the most young childless assessors. However, the maintenance of this order really is not a trivial task. Not always Martian knows all of his parents (and there's nothing to tell about his grandparents!). But if by a mistake first speak a grandson and only than his young appearing great-grandfather, this is a real scandal. 
Your task is to write a program, which would define once and for all, an order that would guarantee that every member of the Council takes the floor earlier than each of his descendants.
输入
The first line of the standard input contains an only number N, 1 <= N <= 100 — a number of members of the Martian Planetary Council. According to the centuries-old tradition members of the Council are enumerated with the natural numbers from 1 up to N. Further, there are exactly N lines, moreover, the I-th line contains a list of I-th member's children. The list of children is a sequence of serial numbers of children in a arbitrary order separated by spaces. The list of children may be empty. The list (even if it is empty) ends with 0.
输出

The standard output should contain in its only line a sequence of speakers' numbers, separated by spaces. If several sequences satisfy the conditions of the problem, you are to write to the standard output any of them. At least one such sequence always exists.

===================================================================================================

题意:

继承关系排序。辈分越长,继承权越靠前。

输入含义:

5              //5个人
0              //1号没有后代
4 5 1 0     //2号的后代是4,5,1(排名不分先后)
1 0           //3号点后代时1
5 3 0
3 0

==========================================================

基本的拓扑排序

1 建图,边的方向是 辈分高->辈分低

2 输出入度为0的点

3 将该点和从该点发出的边删除

4 回到第2步,直到全部输出 

==========================================================

AC代码

#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;
int degree[100]={0}; //每个点的入度
int p[100]={0}; //每个点是否被打印输出过

int main(){
    map< int,vector<int> > graph;
    int num;
    cin>>num;
    for(int i=1;i<num+1;i++){             //建图
        int node;
        cin>>node;
        while(node!=0){
            graph[node].push_back(i);
            degree[node]++;
            cin>>node;
        }
    }
    
    for(int j=0;j<num;j++){
        for(int i=1;i<num+1;i++){
            if(degree[i]==0 && p[i]==0){   //度数为0且没被输出过
                cout<<i<<" ";
                p[i]=1;
                map< int,vector<int> >::iterator it;
                for(it=graph.begin();it!=graph.end();it++){      //删边
                    if(find(it->second.begin(),it->second.end(),i)!=it->second.end())
                        degree[it->first]--;
                }
            }
        }
    }
    return 0;

}


内容概要:本文深入探讨了软件项目配置管理在汽车开发领域的应用及其重要性,强调配置管理不仅是版本控制,更是涵盖标识、追溯、结构化等多方面的深度管控。文章通过对比机械产品和软件产品的标签管理,揭示了软件配置管理的独特挑战。配置管理构建了一个“网”状体系,确保软件产品在复杂多变的开发环境中保持稳定和有序。文中还讨论了配置管理在实际工作中的困境,如命名混乱、文档更新不及时、发布流程冗长等问题,并提出了通过结构可视化、信息同源化、痕迹自动化和基线灵活化等手段优化配置管理的具体方法。 适合人群:具备一定软件开发和项目管理经验的工程师及项目经理,尤其是从事汽车电子软件开发的相关人员。 使用场景及目标:①理解配置管理在汽车软件项目中的核心作用;②学习如何通过工具链(如Polarion、JIRA、飞书等)优化配置管理流程;③掌握结构可视化、信息同源化、痕迹自动化和基线灵活化等关键技术手段,提升项目管理水平。 其他说明:配置管理不仅是技术问题,更涉及到项目管理和团队协作。文中强调了工具链的应用和优化的重要性,但同时也指出,工具本身并不能解决所有问题,关键在于如何合理使用工具并不断优化管理流程。文章呼吁读者成为长期主义者,相信时间的力量,持续改进配置管理工作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值