Relative Relatives
Time Limit: 1000MS |
|
Memory Limit: 30000K |
Total Submissions: 2806 |
|
Accepted: 1210 |
Description
Today is Ted's 100th birthday. A few weeks ago, you were selected by the family to contact all of Ted's descendants and organize a surprise party. To make this task easier, you created an age-prioritized list of everyone descended
from Ted. Descendants of the same age are listed in dictionary order.
The only materials you had to aid you were birth certificates. Oddly enough, these birth certificates were not dated. They simply listed the father's name, the child's name, and the father's exact age when the baby was born.
Input
Input to this problem will begin with line containing a single integer n indicating the number of data sets. Each data set will be formatted according to the following description.
A single data set has 2 components:
- Descendant Count - A line containing a single integer X (where 0 < X < 100) indicating the number of Ted's descendants.
- Birth Certificate List - Data for X birth certificates, with one certificate's data per line. Each certificate's data will be of the format "FNAME CNAME FAGE" where:
- FNAME is the father's name.
- CNAME is the child's name.
- FAGE is the integer age of the father on the date of CNAMEs birth.
Note:
- Names are unique identifiers of individuals and contain no embedded white space.
- All of Ted's descendants share Ted's birthday. Therefore, the age difference between any two is an integer number of years. (For those of you that are really picky, assume they were all born at the exact same hour, minute, second, etc... of their birth
year.)
- You have a birth certificate for all of Ted's descendants (a complete collection).
Output
For each data set, there will be X+1 lines of output. The first will read, "DATASET Y", where Y is 1 for the first data set, 2 for the second, etc. The subsequent X lines constitute your age-prioritized list of Ted's descendants
along with their ages using the format "NAME AGE". Descendants of the same age will be listed in dictionary order.
Sample Input
2
1
Ted Bill 25
4
Ray James 40
James Beelzebub 17
Ray Mark 75
Ted Ray 20
Sample Output
DATASET 1
Bill 75
DATASET 2
Ray 80
James 40
Beelzebub 23
Mark 5
Source
简单说下题意:(每次说这句话的时候就想起了我的英语四级。。泪奔~~)
一个叫Ted的人,现在100岁了,然后他有很多后裔,某一天,你要把这些后裔排个序。。
现在我们不知道每个人的具体年龄,但是知道每个人跟他父亲的年龄差,现在要求我们按年龄排序,年龄一样的按名字的字典序排序。。
思路:BFS+大量STL。。
分享到:
相关推荐
北大POJ1426-Find The Multiple【BFS+同余模】 解题报告+AC代码
北大POJ3026-Borg Maze【BFS+Prim】 解题报告+AC代码
2505 2521 2538 2546 2551 2590 2593 2601 2665 2680 2739 2752 2761 2762 2777 2800 2891 2893 2992 3030 3041 3132 3159 3187 3204 3270 3277 3281 3297 3321 3414 3436 3461 3650 3663 3664 3672 3740
北大POJ3253-POJ3253-Fence Repair【STL优先队列】 解题报告+AC代码
poj 800+ 题目源代码,多年做题积累 包含各种类型经典题目
SPOJ3 AC程序 BF SPOJ3 AC程序 BF SPOJ3 AC程序 BF
很好很强大的POJ分类 新手+进阶+题目完全分类 赶快下载
ACM POJ 解题报告北大POJ 大量解题代码
POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类
西北工业大学POJ试题C++答案代码+课程设计
NULL 博文链接:https://128kj.iteye.com/blog/1750462
北大POJ初级-简单搜索 解题报告+AC代码
北大POJ1207-The 3n + 1 problem 解题报告+AC代码
poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题...
北大POJ1159-Palindrome 解题报告+AC代码
poj习题详解学习ACM的好材料,源代码
POJ 3131 双向BFS解立体八数码问题
北大POJ2002-Squares 解题报告+AC代码
POJ各题算法分类和题目推荐 ACM必看 POJ各题算法分类和题目推荐 ACM必看 POJ各题算法分类和题目推荐 ACM必看
POJ第1861题源码 POJ第1861题源码 POJ第1861题源码