有为杯  Problem I

DAG  有向无环图

A direct acylic graph(DAG),is a directed graph with no directed cycles . That is ,it is formed by a collection of  vertion  of  vertices  and  directed  edges ,  each     edge

connecting   one vertex to another,such that there is no way to way start at some vertex   v  and follow a squence of edges  that eventually  loops  back to v  again.

Given  a  DAG,output how many vertices each vetex can reach (including itself).

这是我根据题目写的算法,请各位品评、品评

#include<iostream>
#define g  10000
using namespace std;
int istr[g];//遍历过的点做标志
int a[g][g];

//深度遍历
void deeptaG(int k,int n){ 
int i;
istr[n]=1;
 for(i=0;i<k;i++){
  if(a[n][i]!=0 && !istr[i]){
  deeptaG(k,i);
  }
 }
}

int main(){

int o,p,i,k,j;
 int n,l;
 cin>>k>>l;
 while(l--){
 cin>>o>>p;
 a[o][p]=1;}

for (i=0;i<k;i++){
  for (int h=0;h<k;h++)
  { istr[h]=0; }
 deeptaG(k,i);
 j=0;
 for(int u=0;u<k;u++)
 if(istr[u]==1){++j;}
cout<<j<<endl;
 }
return  0;
}

2013年 ACM 有为杯 Problem I (DAG)的更多相关文章

  1. [2013山东ACM]省赛 The number of steps (可能DP,数学期望)

    The number of steps nid=24#time" style="padding-bottom:0px; margin:0px; padding-left:0px; ...

  2. 2013 gzhu acm

    题目描述: Word Counting Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 128000/64000 KB (Java/Other ...

  3. ACM - a + b Problem

    前几天看了ACM的第一题,映入眼帘的是一个“简单”的题目: 输入两个数,a,b 输出他们的和. 本着,此乃ACM的原则,便有了如下的思考: ACM的题目肯定很难,a+b,怎么可能直接printf,不行 ...

  4. ACM: A Simple Problem with Integers 解题报告-线段树

    A Simple Problem with Integers Time Limit:5000MS Memory Limit:131072KB 64bit IO Format:%lld & %l ...

  5. 2013年ACM湖南省赛总结

    今年的比赛最大的变化就是改用OJ判题了,相比于PC^2确实省事了不少,至少可以直接复制样例了.题目方面依旧是刘汝佳命题,这点还是相当好的,至少给人以足够的安全感. 开始比赛之后安叔瞬间就把前半部分题目 ...

  6. ACM——A + B Problem (4)

    A + B Problem (4) 时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte总提交:2496            测试通过:124 ...

  7. ACM——A + B Problem (3)

    Home Problems 1086 A + B Problem (3) 时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte总提交:2317 ...

  8. ACM——A + B Problem (2)

    A + B Problem (2) 时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte总提交:2600            测试通过:137 ...

  9. ACM——A + B Problem (1)

    A + B Problem (1) 时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte总提交:5907            测试通过:151 ...

随机推荐

  1. modbus rtu 协议转DLT645-2007和DLT645-1997电表协议转换器定制,

    现场会碰到现场数据为Modbus协议,但是后台系统为DLT645协议系统,本模块支持将工业ModbusRtu协议转换为电表国标协议DLT645协议,支持1997和2007俩种标准,只需要进行简单的配置 ...

  2. collection set

    http://blog.csdn.net/humingfiy/article/details/7946408 Collection:List.SetMap:HashMap.HashTable 如何在它 ...

  3. poj3086---数论

    #include <stdio.h> #include <stdlib.h> int T(int n) { ,i; ;i<=n;i++) { sum+=i; } retu ...

  4. Linux内核中常见内存分配函数(一)

    linux内核中采 用了一种同时适用于32位和64位系统的内存分页模型,对于32位系统来说,两级页表足够用了,而在x86_64系 统中,用到了四级页表. * 页全局目录(Page Global Dir ...

  5. AndroidUI 视图动画-缩放动画效果 (ScaleAnimation)

    放动画效果,可以使用ScaleAnimation: <Button android:id="@+id/btnScale2" android:layout_width=&quo ...

  6. C# linq to xml

    XDocument doc = new XDocument( new XDeclaration("1.0", "utf-8", "yes") ...

  7. Android之TextView的样式类Span的使用具体解释

    Android中的TextView是个显示文字的的UI类,在现实中的需求中,文字有各式各样的样式.TextView本身没有属性去设置实现,我们能够通过Android提供的 SpannableStrin ...

  8. 在 IIS 中配置 ASP.NET 应用程序

     注意事项: 1.注册.NET 如果先安装.net平台,后安装IIS,那么在IIS中可能就没有出现ASP.NET版本的下拉菜单,就要手动注册: 一般.Net版本都存放在:C:\WINDOWS\Micr ...

  9. Spring AOP那些学术概念—通知、增强处理连接点(JoinPoint)切面(Aspect)

    1.我所知道的AOP 初看起来,上来就是一大堆的术语,而且还有个拉风的名字,面向切面编程,都说是OOP的一种有益补充等等.一下让你不知所措,心想着:管不得很多人都和我说AOP多难多难.当我看进去以后, ...

  10. 异常 ORA-00257: archiver error. Connect internal only, until freed

    我oracle 是安装在linux 下. ORA-00257: archiver error. Connect internal only, until freed 得知是错误是由于归档日志(arch ...