HDU 多校1.3
Colorful Tree
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
nodes, each of which has a type of color represented by an integer, where the color of node i
is ci
.
The path between each two different nodes is unique, of which we define the value as the number of different colors appearing in it.
Calculate the sum of values of all paths on the tree that has n(n−1)2
paths in total.
For each test case, the first line contains one positive integers n
, indicating the number of node. (2≤n≤200000)
Next line contains n
integers where the i
-th integer represents ci
, the color of node i
. (1≤ci
≤n)
Each of the next n−1
lines contains two positive integers x,y
(1≤x,y≤n,x≠y)
, meaning an edge between node x
and node y
.
It is guaranteed that these edges form a tree.
: y
indicates the case number starting from 1
and y
denotes the answer of corresponding case.
1 2 1
1 2
2 3
6
1 2 1 3 2 1
1 2
1 3
2 4
2 5
3 6
Case #2: 29
HDU 多校1.3的更多相关文章
- 2018 HDU多校第四场赛后补题
2018 HDU多校第四场赛后补题 自己学校出的毒瘤场..吃枣药丸 hdu中的题号是6332 - 6343. K. Expression in Memories 题意: 判断一个简化版的算术表达式是否 ...
- 2018 HDU多校第三场赛后补题
2018 HDU多校第三场赛后补题 从易到难来写吧,其中题意有些直接摘了Claris的,数据范围是就不标了. 如果需要可以去hdu题库里找.题号是6319 - 6331. L. Visual Cube ...
- 2015 HDU 多校联赛 5363 Key Set
2015 HDU 多校联赛 5363 Key Set 题目: http://acm.hdu.edu.cn/showproblem.php? pid=5363 依据前面给出的样例,得出求解公式 fn = ...
- 2015 HDU 多校联赛 5317 RGCDQ 筛法求解
2015 HDU 多校联赛 5317 RGCDQ 筛法求解 题目 http://acm.hdu.edu.cn/showproblem.php? pid=5317 本题的数据量非常大,測试样例多.数据 ...
- [HDU多校]Ridiculous Netizens
[HDU多校]Ridiculous Netizens 点分治 分成两个部分:对某一点P,连通块经过P或不经过P. 经过P采用树形依赖背包 不经过P的部分递归计算 树型依赖背包 v点必须由其父亲u点转移 ...
- 【杂题总汇】HDU多校赛第十场 Videos
[HDU2018多校赛第十场]Videos 最后一场比赛也结束了…… +HDU传送门+ ◇ 题目 <简要翻译> 有n个人以及m部电影,每个人都有一个快乐值.每场电影都有它的开始.结束时间和 ...
- hdu多校1002 Balanced Sequence
Balanced Sequence Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s) ...
- HDU多校(Distinct Values)
Problem Description Chiaki has an array of n positive integers. You are told some facts about the ar ...
- hdu多校6
这个场要恶心死我了.. 1001 积分题,不要四舍五入 //#pragma comment(linker, "/stack:200000000") //#pragma GCC op ...
- hdu 多校第一场
1001 思路:打表可以发现只有3|n 和 4|n 的情况有解,判一下就好啦. #include<bits/stdc++.h> #define LL long long #define f ...
随机推荐
- 【bzoj2768/bzoj1934】[JLOI2010]冠军调查/[Shoi2007]Vote 善意的投票 最小割
bzoj2768 题目描述 一年一度的欧洲足球冠军联赛已经进入了淘汰赛阶段.随着卫冕冠军巴萨罗那的淘汰,英超劲旅切尔西成为了头号热门.新浪体育最近在吉林教育学院进行了一次大规模的调查,调查的内容就是关 ...
- 关于网站转码(SiteApp转码)
1.Siteapp页面转码的意义?在百度移动搜索引擎中为更好满足用户信息需求,会同时为用户提供pc网页和mobile网页,但目前大多数PC页在移动终端中直接浏览的体验较差(交互.兼容和流量等).因此为 ...
- HDU——1394 Minimum Inversion Number
Problem Description The inversion number of a given number sequence a1, a2, ..., an is the number of ...
- iconfont字体图标
1.1.进入阿里图标网站 http://www.iconfont.cn/ 1.2.在购物车里添加自己需要的字体图标 1.3.下载代码 1.4.解压过后,找到iconfont.css,放在你的项目里,需 ...
- jaspersoft中分组打印
一:前言 使用IReport已经四个月了,最近在做一个保镖,是要按照类型分类,并且这些类型要横着打印,最后还要算这个类型金额的总值,这张报表现是说需要用到子报表,最后和一个同事一起用group来分组做 ...
- salt-api的使用
curl -k https://192.168.74.129:8006/ -H "Accept: application/x-yaml" -H "X-Auth-Token ...
- 【51NOD】1717 好数
[算法]数学 [题意]a数组初始为0,t=1~n,每次01翻转t的倍数,最终为0的数字定义为好数,求好数个数 [题解]一个数字为好数的条件是翻转偶数次,也即一个数是好数当且仅当有偶数个因子时. 因子都 ...
- tyvj1048 田忌赛马
描述 中国古代的历史故事“田忌赛马”是为大家所熟知的.话说齐王和田忌又要赛马了,他们各派出N匹马,每场比赛,输的一方将要给赢的一方200两黄金,如果是平局的话,双方都不必拿出钱.现在每匹马的速 ...
- CodeMirror编辑器文本框Textarea代码高亮插件,CodeMirror的简单实用例子
CodeMirror是一个用于编辑器文本框textarea代码高亮javascript插件,为各种编程语言实现关键字,函数,变量等代码高亮显示,丰富的api和可扩展功能以及多个主题样式,能满足您各种项 ...
- 智联招聘获取python岗位的数据
import requests from lxml import html import time import pandas as pd from sqlalchemy import create_ ...