尺取法
live4m
老菜逼了
展开
-
CodeForces - 1196 D2.RGB Substring (hard version) (尺取法)
题意: 给T表示T组案例, 每组案例: 给n,k,和一个字符串,字符串的长度为n 现在可以任意修改字符串里的字母,要求修改后的字符串存在长度为k的子串 该子串也是"RGBRGBRGB…"(无限延长) 的子串 问最少需要修改多少次 Example Input 3 5 2 BGGGG 5 3 RBRGR 5 5 BBBRR Output 1 0 3 分析: 枚举修改之后的字符串开头为R或G或B 然后尺...原创 2019-08-22 19:03:39 · 119 阅读 · 0 评论 -
hdu5672 String (尺取)
String There is a string S.S only contain lower case English character.(10≤length(S)≤1,000,000) How many substrings there are that contain at least k(1≤k≤26) distinct characters? Input There are multi...原创 2019-09-09 00:02:36 · 133 阅读 · 0 评论 -
hdu5056 Boring count (尺取)
Problem Description You are given a string S consisting of lowercase letters, and your task is counting the number of substring that the number of each lowercase letter in the substring is no more tha...原创 2019-09-13 10:26:32 · 149 阅读 · 0 评论 -
poj2566 Bound Found (尺取)
题意: 给出一个整数序列,求一段连续子序列,满足连续子序列之和最接近所给出的t。输出该段子序列之和及左右端点。 思路: 计算前缀和,和下标i一起存起来然后排序。 因为abs(sum[r]-sum[l])=abs(sum[l]-sum[r]) 所以可以忽略下标大小关系 这时候 sum[r]-sum[l]随着r增大而增大,随着l增大而减小,具有单调性 每次比较当前sum[r]-sum[l]与t的差值,...原创 2019-10-06 17:06:52 · 107 阅读 · 0 评论