【Codeforces 741D】Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths

相关链接

题目传送门:http://codeforces.com/contest/741/problem/D
中文题面:https://blog.sengxian.com/solutions/cf-741d

解题报告

看起来这个串的定义非常强的样子,但仔细观察不难发现,就是出现次数为奇数的字母最多出现一个
于是我们定时一个二进制状态$f_{i,j}$表示$i$到$j$这段路径中哪些字符出现了奇数次

我们考虑在每一条合法路径的LCA处将其统计
于是就变成了子树相关问题,于是非常自然想到启发式合并

考虑从子树最大的儿子那里继承集合,其他的儿子的集合暴力加入
因为走一条边,需要异或一个值,整个集合的转移我们可以记录一个标记,然后在插入时使其生效
考虑统计的话,我们在暴力插入的时候,枚举是哪一位不同,单次查询是$O(22)$的
又因为加入是$O(1)$的,所以总的时间复杂度$O(n \log n \cdot 22)$

14 thoughts to “【Codeforces 741D】Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths”

  1. Can I just say what a relief to find someone who actually knows what theyre talking about on the internet. You definitely know how to bring an issue to light and make it important. More people need to read this and understand this side of the story. I cant believe youre not more popular because you definitely have the gift.

  2. 341140 598034This style is steller! You naturally know how to maintain a reader amused. Between your wit and your videos, I was almost moved to start my own blog (effectively, almostHaHa!) Amazing job. I really enjoyed what you had to say, and a lot more than that, how you presented it. Too cool! 10739

  3. 272145 385577I take excellent pleasure in reading articles with quality content material. This write-up is one such writing that I can appreciate. Keep up the very good function. 417975

  4. 419123 579757Wow that was strange. I just wrote an incredibly long comment but after I clicked submit my comment didnt appear. Grrrr properly Im not writing all that more than once more. Regardless, just wanted to say great weblog! 894844

  5. 677350 641242Youre the top, It is posts like this that keep me coming back and checking this web site regularly, thanks for the information! 39492

  6. Hi there! This is kind of off topic but I need some help from an established blog. Is it hard to set up your own blog? I’m not very techincal but I can figure things out pretty quick. I’m thinking about making my own but I’m not sure where to start. Do you have any tips or suggestions? With thanks

Leave a Reply

Your email address will not be published. Required fields are marked *