codeforces 814C An impassioned circulation of affection
来源:互联网 发布:淘宝怎么看正品 编辑:程序博客网 时间:2024/05/21 19:36
每次做cf基本就前两个,第三个就死掉了。。
这个题呢,看到题还是有有点想法的。先想dp。。做不出来。后来想到尺取法。。结果错了。。。还是去看了题解。。以后还是先写c题。。。
参考:http://blog.csdn.net/qq_33183401/article/details/72906503
尺取法还是很好想的
#include <cstdio>#include <cstring>#define max(a,b) a>b?a:bconst int MAXN = 1510;char str[MAXN];int n,m,q,r,len,res;char c;int main(){ int l,r; scanf("%d",&n); scanf("%s",str); scanf("%d",&q); while(q--) { res = 0; len = 0; l = 0; scanf(" %d %c",&m,&c); for(r = 0; r < n; ++r) { if(str[r] != c) ++len; while(len > m) { if(str[l] != c) --len; ++l; } res = max(res,r-l+1); } printf("%d\n",res); } return 0;}
阅读全文
0 0
- codeforces C. An impassioned circulation of affection
- 【Codeforces 814 C. An impassioned circulation of affection】+ 尺取法
- codeforces 814C An impassioned circulation of affection
- codeforces 814C An impassioned circulation of affection
- codeforces 814 C An impassioned circulation of affection
- Codeforces 814C-An impassioned circulation of affection
- codeforces 814 C. An impassioned circulation of affection(暴力)
- Codeforces 814C An impassioned circulation of affection【Dp】
- codeforces 814C An impassioned circulation of affection
- Codeforces 814 C An impassioned circulation of affection
- Codeforces 814C An impassioned circulation of affection (dp)
- CodeForces-814C An impassioned circulation of affection
- Codeforces 814C An impassioned circulation of affection(dp)
- 814C An impassioned circulation of affection
- Codeforces#418C An impassioned circulation of affection
- Codeforces Round #418 C--An impassioned circulation of affection
- Codeforces#418 An impassioned circulation of affection
- An impassioned circulation of affection CodeForces
- JQuery-form表单提交前验证、单选框是否选中、删除记录时验证经验总结
- 2017.06.08学习总结
- short text conversation: retrieval
- 搭建SVN服务器
- Web 前沿——HTML5 FormData 对象的使用
- codeforces 814C An impassioned circulation of affection
- js时间戳对象和标准格式字符串之间的转换方法
- 北京2017年7月开始 社保最低缴费
- BZOJ 3223: Tyvj 1729 文艺平衡树 splay
- TextView vs Button
- jQuery(二、DOM)
- H5移动端知识点总结
- nginx配置ajax请求跨域
- 面向对象设计对象之间关系---依赖、关联、聚合和组合