1094. The Largest Generation
2015-08-19 19:19
393 查看
#include <cstdio> #include <map> #include <vector> #include <cstring> #include <algorithm> using namespace std; #define MAX 100 map<int , vector<int> > data ; int ans[MAX] ; int maxChild = 0 , maxLevel = 0 ; void bfs(int p , int level) { int i ; int tempChild = 0 ; ans[level] ++ ; if( ans[level] > maxChild ) { maxChild = ans[level] ; maxLevel = level ; } if( data.count(p) == 0 ) { return ; } for( i = 0 ; i < data[p].size() ; i ++ ) { bfs( data[p][i] , level + 1) ; } } int main(void) { int N , count ; memset( ans , 0 , sizeof( ans ) ) ; //freopen("input.txt" , "r" , stdin) ; scanf("%d %d" , &N , &count); while(count--) { int p , child ; vector<int>temp ; scanf("%d %d" , &p , &child); while(child--) { int t ; scanf("%d" , &t); temp.push_back(t) ; } data[p] = temp ; } bfs(1 , 1) ; printf("%d %d\n" , maxChild , maxLevel); return 0 ; }
相关文章推荐
- 8.19 多线程的几种实现方式
- POJ 3279 Dungeon Master
- 在navgationController中添加UISegmentedControl
- wowza简介
- ObjectiveC开发教程--字符串的基本操作处理方法
- 题目:尾部的零
- ItailorCode
- ajax(三) ajax提交表单、ajax实现文件上传
- 什么是进程
- 第十章 面向对象编程:继承和多态
- 题目:将整数A转换为B
- oracle游标:查询并打印员工的姓名和薪水
- iOS中Storyboard使用要点记录
- EF里Guid类型数据的自增长、时间戳和复杂类型的用法
- 题目:字符串查找
- NIO(JDK1.4)--选择器Selector
- 阿里云server安全设定
- 时间戳
- OC中nil、Nil、NULL、NSNull的区别
- android开发 解决启动页空白或黑屏问题