尺取法--An impassioned circulation of affection
来源:互联网 发布:赵丽颖用什么软件直播 编辑:程序博客网 时间:2024/06/04 17:57
cfR418-c
6koyomi31 o4 o4 mq个问讯,每次可以repaint m个字符变成c,求最长连续的字符全为c的长度。
连续,可以用尺取。
#include <iostream>
#include <string>
#include <cstdio>
using namespacestd;
string s;int n;
void solve(int m,char c)
{
int l =0,r = 0,res =0;
for(;;)
{
while (m >0 && r < n) {
if (s[r] != c) {
m --;
}
r ++;
}
while (m ==0 && s[r] == c) {
r ++;
}
if (l >= n) {
break;
}
res = max(res,r - l);
if (s[l] != c) {
m ++;
}
l ++;
}
cout << res << endl;
}
int main()
{
cin >> n;
cin >> s;
int q;cin >> q;
int m;char c;
while (q --) {
scanf("%d %c",&m,&c);
solve(m,c);
}
return0;
}
阅读全文
0 0
- 尺取法--An impassioned circulation of affection
- 【Codeforces 814 C. An impassioned circulation of affection】+ 尺取法
- Codeforces-An impassioned circulation of affection (尺取法)
- C. An impassioned circulation of affection-尺取法或者DP
- An impassioned circulation of affection
- codeforces 814C An impassioned circulation of affection 尺取法或者预处理
- 814/ C. An impassioned circulation of affection(尺取法或者DP)
- Codeforces-An impassioned circulation of affection (动态规划/尺取法)
- codeforces 814C An impassioned circulation of affection(尺取法模板)
- 814C An impassioned circulation of affection
- Codeforces814C. An impassioned circulation of affection
- C. An impassioned circulation of affection
- C. An impassioned circulation of affection
- codeforces C. An impassioned circulation of affection
- Codeforces#418 An impassioned circulation of affection
- An impassioned circulation of affection CodeForces
- codeforces 814C An impassioned circulation of affection
- coderforces--418 div2 C. An impassioned circulation of affection
- jquery EasyUI数据表格datagrid中load,reload,loadData方法的区别
- 卡特兰数
- javascript 获取当前系统时间
- 关于JS的浏览器兼容1
- 获取数据库表结构
- 尺取法--An impassioned circulation of affection
- Could not resolve type alias ''
- Object.keys()js 把对象按照属性名的字母顺序进行排列
- Java泛型中E、T、K、V等的含义
- PAT 1066 图像过滤
- 临时扩大swap分区大小
- eclipse fail to load the JNI ...
- JS控制静态页面之间传递参数获取参数并应用(window.location)
- LeetCode 60. Permutation Sequence