Processing math: 100%
[Codeforces Round #447][Codeforces 894C]Marco and GCD Sequence
[Educational Codeforces Round 6][Codeforces 620C]Pearls in a Row

[Educational Codeforces Round 6][Codeforces 620E]New Year Tree

Zarxdy34 posted @ 2017年11月22日 12:20 in Codeforces with tags DFS序 线段树 , 718 阅读

    题意:给出一棵以1为根的树,每个节点有一个颜色,颜色数<=60。有两种操作,操作1为将一棵以v为根的子树中的所有节点颜色变为ai,操作2为查询以v为根的子树中的所有节点有多少种不同颜色。

    题解:考虑到颜色最多只有60种,所以可以用一个long long按位来记录颜色是否出现。对整棵树做出DFS序,然后建线段树,然后就是区间查询区间修改就好了。

 


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter