题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5583 一个01串,求修改一个位置,使得所有数均为0或1的子串长度的平方和最大.先分块,然后统计好原来的结果,每次更新块,更新最大值. #include <algorithm> #include <iostream> #include <iomanip> #include <cstring> #include <climits> #include &l…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5583 Kingdom of Black and White Time Limit: 2000/1000 MS (Java/Others)   Memory Limit: 65536/65536 K (Java/Others) Problem Description In the Kingdom of Black and White (KBW), there are two kinds of frog…
Kingdom of Black and White Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5583 Description In the Kingdom of Black and White (KBW), there are two kinds of frogs: black frog and white frog. Now N frogs are stand…
Problem Description In the Kingdom of Black and White (KBW), there are two kinds of frogs: black frog and white frog. Now N frogs are standing in a line, some of them are black, the others are white. The total strength of those frogs are calculated b…
Kingdom of Black and White Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 585    Accepted Submission(s): 193 Problem Description In the Kingdom of Black and White (KBW), there are two kinds of…
Kingdom of Black and White Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3735    Accepted Submission(s): 1122 Problem Description In the Kingdom of Black and White (KBW), there are two kinds o…
http://acm.hdu.edu.cn/showproblem.php?pid=5583 题意: 给出一个01串,现在对这串进行分组,连续相同的就分为一组,如果该组内有x个数,那么就对答案贡献x*x,现在最多可以修改原串中的一个字符,问答案最大可以为多少. 思路:暴力求解. 一开始只需要预处理分块,计算出每一分块的个数,然后暴力处理一下即可,需要注意分块数为1的情况,此时左右两边都要合并起来. #include<iostream> #include<cstdio> #inclu…
Kingdom of Black and White                                                                                                            Time Limit: 2000/1000 MS (Java/Others)                                                                             …
5573 Binary Tree(构造) 题意:给你一个二叉树,根节点为1,子节点为父节点的2倍和2倍+1,从根节点开始依次向下走k层,问如何走使得将路径上的数进行加减最终结果得到n. 联想到二进制. 思路和这个差不多吧:http://blog.csdn.net/u013068502/article/details/50094561 #include <set> #include <queue> #include <cstdio> #include <vector…
「WC2018」即时战略 考虑对于一条链:直接随便找点,然后不断问即可. 对于一个二叉树,树高logn,直接随便找点,然后不断问即可. 正解: 先随便找到一个点,问出到1的路径 然后找别的点,考虑问出来第一个从1过来的未知位置,就可以一口气问下去了. 怎么找? logn询问次数 法一: 点分治 有点类似:CF772E Verifying Kingdom 可以直接确定走向 暴力插入点,替罪羊重构 O(nlog^2n) 法二: LCT 直接在实链上不断二分,然后跳到下一个实链上 复杂度分析可以类比a…