题目链接 Problem Description We define the distance of two strings A and B with same length n is disA,B=∑i=0n−1|Ai−Bn−1−i| The difference between the two characters is defined as the difference in ASCII. You should find the maximum length of two non-over…
We define the distance of two strings A and B with same length n is dis A,B =∑ i=0 n−1 |A i −B n−1−i | disA,B=∑i=0n−1|Ai−Bn−1−i| The difference between the two characters is defined as the difference in ASCII. You should find the maximum length of tw…
http://acm.hdu.edu.cn/showproblem.php?pid=6103 题意: 给出一个字符串,在其中找两串互不重叠的子串,计算它们之间的dis值,要求dis值小于等于m,求能选的子串的最大长度. 思路: 由于这两个子串是互不重叠的,那么这两个子串之间的间隔可以是奇数也可以是偶数,针对这两种情况我们枚举中心点,然后尺取法处理,具体看代码就懂了. #include<iostream> #include<algorithm> #include<cstring…
多校的题,摆明了数学题,但是没想出来,蠢爆了,之前算了半天的s[i][j]的和,其实是积.其实比赛的时候我连log(s[i][j])+1是s[i][j]的位数都没看出来,说出来都丢人. 知道了这个之后,就枚举二进制数的每一位,因为元素都是非负数,所以sum数组是非降的,这里用到了尺取法,之前也是听说过,应该是做过吧,不太记得了. 因为[2k-1,2k)的位数是k,枚举时,固定左端点,在sum数组找到最小的大于等于2k-1,最大的小于2k的点,这中间的点和左端点的s[i][j]就对于当前的k满足条…
card card card Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1774    Accepted Submission(s): 792 Problem Description As a fan of Doudizhu, WYJ likes collecting playing cards very much. One day…
Kirinriki Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2169    Accepted Submission(s): 879 Problem Description We define the distance of two strings A and B with same length n isdisA,B=∑i=0n−…
题目链接:Kirinriki 题目描述: 找两个不重叠的字符串A,B. 使得dis(A,B)<=m;\(dis(A,B)= \sum _{i=0}^{n-1} \left | A_i-B_{n-1-i} \right |\).求最长的字符串长度. 思路: 官方题解,双指针维护.简单题.枚举对称中心. 在这里我给出我常用的双指针的写法. int a[N]; int l=0,r=0,val=0; while(r没有越界) //如果满足条件 { if(val+a[r]<=key) // 加上 a[r…
Face The Right Way Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 2899   Accepted: 1338 Description Farmer John has arranged his N (1 ≤ N ≤ 5,000) cows in a row and many of them are facing forward, like good cows. Some of them are facin…
A Bit Fun Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description There are n numbers in a array, as a0, a1 ... , an-1, and another number m. We define a function f(i, j) = ai|ai+1|ai+2| ... | aj . Wher…
Problem Description We define the distance of two strings A and B with same length n isdisA,B=∑(i=0  n−1)  |A[i]−B[n−1−i]|The difference between the two characters is defined as the difference in ASCII.You should find the maximum length of two non-ov…