A 模拟

B 发现对于每个连通块,只有为完全图才成立,然后就dfs

C 构造  想了20分钟才会,一开始想偏了,以为要利用相邻NO YES的关系再枚举,其实不难。。

考虑对于顺序枚举每一个NO/YES,与前一个需要用的的字符串有k-1个交集,只多了一个string

于是只要保证k-1个string不同,只通过当前的string来影响答案,

若YES,开一个新的串; NO,则和第一个串一样,以此让这个相同串在下一次枚举中消失。。

//怎么想到?  其实NO可能有多个相同名字,关系就很乱了,我们希望只有1个名字重复,且只重复1次,然后再接着考虑

D 考虑如何求树上所有点对的距离和 : 只需求出每条边对答案的贡献累加即可。

原问题转化为求所有  =L/k + f(L,k)/k  f(L,k):L最少加几才能是k的倍数

第一部分可以直接O(n)求,f(L,k)可以通过L%k的值得出,问题转化为求所有L%k的值为0..k-1分别有几组。

待统计的二点形成链,链有2种,一种是有某个点为LCA,否则是另一种。

对于情况1,直接dp O(nk)

情况2,dp记录前缀和,将孩子信息合并,O(n*k^2)

这数数题还是挺好的

Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1)的更多相关文章

  1. Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 菜鸡只会ABC!

    Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 全场题解 菜鸡只会A+B+C,呈上题解: A. Bear and ...

  2. Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) C. Bear and Different Names 贪心

    C. Bear and Different Names 题目连接: http://codeforces.com/contest/791/problem/C Description In the arm ...

  3. Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) B - Bear and Friendship Condition 水题

    B. Bear and Friendship Condition 题目连接: http://codeforces.com/contest/791/problem/B Description Bear ...

  4. 【树形dp】Codeforces Round #405 (rated, Div. 1, based on VK Cup 2017 Round 1) B. Bear and Tree Jumps

    我们要统计的答案是sigma([L/K]),L为路径的长度,中括号表示上取整. [L/K]化简一下就是(L+f(L,K))/K,f(L,K)表示长度为L的路径要想达到K的整数倍,还要加上多少. 于是, ...

  5. Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1)A B C 水 并查集 思路

    A. Bear and Big Brother time limit per test 1 second memory limit per test 256 megabytes input stand ...

  6. 【构造】Codeforces Round #405 (rated, Div. 1, based on VK Cup 2017 Round 1) A. Bear and Different Names

    如果某个位置i是Y,直接直到i+m-1为止填上新的数字. 如果是N,直接把a[i+m-1]填和a[i]相同即可,这样不影响其他段的答案. 当然如果前面没有过Y的话,都填上0就行了. #include& ...

  7. Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) E

    Description Bear Limak prepares problems for a programming competition. Of course, it would be unpro ...

  8. Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) D

    Description A tree is an undirected connected graph without cycles. The distance between two vertice ...

  9. Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) C

    Description In the army, it isn't easy to form a group of soldiers that will be effective on the bat ...

随机推荐

  1. 查询表的大小(mysql)

    --所有表的大小 select concat(round(sum(DATA_LENGTH/1024/1024),2),'M') from information_schema.tables where ...

  2. 团队介绍&学长采访

    1. 团队介绍 刘畅 博客园ID:森高Slontia 身份:PM 个人介绍: 弹丸粉 || 小说创作爱好者 || 撸猫狂魔 我绝对不知道,我一个写代码的怎么就当PM去了? 张安澜 博客园ID:Mins ...

  3. 数据库与数据仓库的比较Hbase——Hive

    数据仓库(Data Warehouse)是一个面向主题的(Subject Oriented).集成的(Integrate).相对稳定的(Non-Volatile).反映历史变化(Time Varian ...

  4. scrum立会报告+燃尽图(第二周第七次)

    此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2252 一.小组介绍 组名:杨老师粉丝群 组长:乔静玉 组员:吴奕瑶.公冶 ...

  5. 20181023-10 Alpha阶段第2周/共2周 Scrum立会报告+燃尽图 07

    作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2290 Scrum master:范靖旋 一.小组介绍 组长:王一可 组员: ...

  6. 王者荣耀交流协会--第3次Scrum会议

    Scrum master:王玉玲 要求1:工作照片 要求2:时间跨度:2017年10月15号  6:00--6:24  共计24min要求3:地点:传媒西楼204,会议室要求4:立会内容:1.从昨日会 ...

  7. 团队作业——王者光耀:team

    光耀101  <光耀101>是福州大学数计学院计算机专业推出的中国首部程序猿脱发养成节目.由张栋担任发起人,刘晨瑶.畅畅担任导师.  该节目召集了你猜多少位选手,通过任务.训练.考核,让选 ...

  8. HDU 5183 Negative and Positive (NP) 前缀和+哈希

    题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5183 bc(中文):http://bestcoder.hdu.edu.cn/contests ...

  9. 新手使用github过程记录

    初次接触github,记录下我的使用过程.一开始确实有些懵,但好在网上这类的教程有很多,过程也很详细易懂,按照网上的教程走完全没问题,感谢无私分享辛苦整理的各位前辈们. 注册github账号 创建一个 ...

  10. timestamp 学习

    该答案摘抄自CSDN. 哇,奇迹,跨度三年了,不知道楼主是否已经解决了此问题. 路过,简单说一下,timestamp 主要是记录该行的最后修改时间戳, 注意,这个时间戳是不可以转换为时间的,只能标注该 ...