1022

简单拓扑 不能直接dfs 可能有不联通的

     #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
using namespace std;
vector<int>ed[];
int n,pa[],de[];
void topo()
{
int i,j;
for(i = ; i <= n ; i++)
{
for(j = ; j <= n ;j++)
{
if(de[j]==)
{
de[j] = -;
pa[i] = j;
for(int k = ; k < (int)ed[j].size() ; k++)
de[ed[j][k]]--;
break;
}
}
}
}
int main()
{
int i,k;
scanf("%d",&n);
for(i = ; i <= n ; i++)
{
while(scanf("%d",&k)&&k)
{
ed[i].push_back(k);
de[k]++;
}
}
topo();
for(i = ; i < n ;i++)
printf("%d ",pa[i]);
printf("%d\n",pa[n]);
return ;
}

1022. Genealogical Tree(topo)的更多相关文章

  1. timus 1022 Genealogical Tree(拓扑排序)

    Genealogical Tree Time limit: 1.0 secondMemory limit: 64 MB Background The system of Martians’ blood ...

  2. Genealogical tree(拓扑结构+邻接表+优先队列)

    Genealogical tree Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) ...

  3. POJ 2367:Genealogical tree(拓扑排序模板)

    Genealogical tree Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7285   Accepted: 4704 ...

  4. POJ 2367:Genealogical tree(拓扑排序)

    Genealogical tree Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2738 Accepted: 1838 Spe ...

  5. poj 2367 Genealogical tree (拓扑排序)

    火星人的血缘关系很奇怪,一个人可以有很多父亲,当然一个人也可以有很多孩子.有些时候分不清辈分会产生一些尴尬.所以写个程序来让n个人排序,长辈排在晚辈前面. 输入:N 代表n个人 1~n 接下来n行 第 ...

  6. poj 2367 Genealogical tree【拓扑排序输出可行解】

    Genealogical tree Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3674   Accepted: 2445 ...

  7. poj——2367  Genealogical tree

    Genealogical tree Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6025   Accepted: 3969 ...

  8. 2015暑假多校联合---Mahjong tree(树上DP 、深搜)

    题目链接 http://acm.split.hdu.edu.cn/showproblem.php?pid=5379 Problem Description Little sun is an artis ...

  9. Device Tree(三):代码分析【转】

    转自:http://www.wowotech.net/linux_kenrel/dt-code-analysis.html Device Tree(三):代码分析 作者:linuxer 发布于:201 ...

随机推荐

  1. jQuery阻止冒泡和HTML默认操作

    1:jQuery是一个快捷简便的JavaScript框架,说道框架可以直接理解为就是对原来底层的东西进行了封装使得开发者能够利用这个框架快速开发. 2:在当今的各个浏览器中都支持事件的冒泡,所谓的冒泡 ...

  2. js判断IE6(推荐方法一)

    不得不使用判断的方法 //方法1:推荐 if ( /MSIE 6/.test(navigator.userAgent)){ } //方法2: if ( navigator.appVersion.ind ...

  3. MoneyUtil

    public class MoneyUtil {       private final static String[] CN_Digits = { "零", "壹&qu ...

  4. php安装libevent

    libevent扩展安装 libevent-2.0.16-stable.tar http://libevent.org/ [plain] view plaincopy cd libevent-2.0. ...

  5. ACE_linux:UDP通信

    1.涉及类 ACE_INET_Addr//ACE网络地址ACE_SOCK_Dgram//ACE报文 2.简介 UDP通信时无需像TCP那样建立连接和关闭连接,TCP编程时需要通过accept和conn ...

  6. 用AJAX自定义日历

    需求分析 在一些购物网站中,都会有促销活动,这些活动都在日历上标注出来,如何通过Ajax让日历 通过读取数据库中的信息,正确的把促销活动标注在日历上,本文通过自定义日历来实现这 个问题. 技术难点 日 ...

  7. SQL动态更新表字段 传入字段可能为空

    小技巧: 项目组有修改产品的基本信息字段 但有时候传入的字段可能为空 也可能不为空  动态修改表中字段. USE [BetaProductMarket_DB] GO )) BEGIN DROP PRO ...

  8. JavaScript 常用方法总结

    经常使用的 JS 方法,今天记下,以便以后查询 /* 手机类型判断 */ var BrowserInfo = { userAgent: navigator.userAgent.toLowerCase( ...

  9. Jsonp 跨域请求实例

    关于jsonp的一个实例,其实自己也不是很了解,今天下午稍微研究了一下: 简单来说,jsonp就是为了两个不同网站之间数据传递而产生的,主要用于js脚本,因为浏览器本身是禁止跨域访问的: 本机实例: ...

  10. Jquery异步请求简单实例(转)

    本文引用自Xingsoft. 一.Jquery向aspx页面请求数据 前台页面JS代码:             $("#Button1").bind("click&qu ...