http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2806
名字的价值
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
每 个人都有名字,名字都是唯一的不存在重复现象。现在假设名字都是由小写字母组成并且长度不超过10,我们赋予每个名字一个初始价值。价值是正整数并且不超 过100,如果第j个人的名字是第i个人的前缀并且前缀长度最大,我们就说j是i的父节点,比如:名字A为:a;名字B为ab;名字C为abc; A是C 的前缀,B也是C的前缀,但是B的长度为2比A的长度大,那么B就是C的父节点. 由此规则建树,从叶子节点到根,父节点的价值=父节点本身的价值+孩子 节点的价值。 求最后各个名字的价值
输入
一个整数T,代表数据组数
对于每一组数据输入第一行为一个整数N(0<N<=10^5)代表N个名字,第二行为N个名字,第三行为N个名字的价值
名字都是唯一的
输出
输出N个对应的名字的价值,按照输入的顺序输出(操作完成后最终价值)
示例输入
示例输出
提示
大数据输入,建议用scanf
题解:就是水水的字典树,没什么好讲的。