【codeforces 801A】Vicious Keyboard
【题目链接】:http://codeforces.com/contest/801/problem/A
【题意】
一个字符串只由VK组成;
让你修改一个字符;
使得剩下的字符串里面子串VK的个数最大;
【题解】
枚举修改哪一个字符;
然后获取剩余的字符里面VK的数的个数;
取MAX就好;
【Number Of WA】
0
【完整代码】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) cin >> x
#define pri(x) cout << x
#define ms(x,y) memset(x,y,sizeof x)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 110;
string s;
int ans;
int cnt(string ts)
{
int now = 0;
int len = ts.size();
rep1(i,1,len-1)
{
if (s[i-1]=='V'&&s[i]=='K')
now++;
}
return now;
}
int main()
{
//freopen("F:\\rush.txt","r",stdin);
ios::sync_with_stdio(false);
cin >> s;
int len = s.size();
ans = cnt(s);
rep1(i,0,len-1)
{
char t = s[i];
if (t=='V')
s[i]='K';
else
s[i]='V';
ans = max(ans,cnt(s));
s[i] = t;
}
cout << ans << endl;
//printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
return 0;
}
【codeforces 801A】Vicious Keyboard的更多相关文章
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
- 【codeforces 709B】Checkpoints
[题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...
- 【codeforces 709C】Letters Cyclic Shift
[题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...
- 【Codeforces 429D】 Tricky Function
[题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...
- 【Codeforces 670C】 Cinema
[题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ...
- 【codeforces 515D】Drazil and Tiles
[题目链接]:http://codeforces.com/contest/515/problem/D [题意] 给你一个n*m的格子; 然后让你用1*2的长方形去填格子的空缺; 如果有填满的方案且方案 ...
随机推荐
- 2-sat总结
算法 构造一个有向图G,每个变量xi拆成两个点2i和2i+1 分别表示xi为假,xi为真 那么对于“xi为真或xj为假”这样的条件 我们就需要连接两条边 2*i —>2*j(表示如果i为假,那么 ...
- UVALive 4671 K-neighbor substrings 巧用FFT
UVALive4671 K-neighbor substrings 给定一个两个字符串A和B B为模式串.问A中有多少不同子串与B的距离小于k 所谓距离就是不同位的个数. 由于字符串只包含a和 ...
- linux下的so、o、lo、a、la文件的区别
o: 编译的目标文件a: 静态库,其实就是把若干o文件打了个包so: 动态链接库(共享库) lo: 使用libtool编译出的目标文件,其实就是在o文件中添加了一些信息la: 使用libtool编译出 ...
- 42.extjs Combobox动态加载数据问题,mode:local 还是remote
问题: Java代码 var fabircTypeDs = new Ext.data.Store({ proxy: new Ext.data.HttpProxy({ url: 'province. ...
- Spring实例化bean之后的处理, 关于BeanPostProcessor接口的使用
业务需求:缓存页面,展示需要缓存的所有对象,每类对象在字典表中有编码对应,点击某个对象可以缓存某类对象,每类对象都有自己的缓存runner(弱弱的说一句,本人看到这里的第一反应就是if-else,捂脸 ...
- openpyxl python操作Excel表格,
这里openpyxl只支持xlsx格式的Excel,openpyxl使用起来会更方便一些,所以如果只操作小流水线文件的话,那么可以优先选择openpyxl,如果要兼容xls的话,就使用xlrd/xlw ...
- 【转】Java 集合系列04之 fail-fast总结(通过ArrayList来说明fail-fast的原理、解决办法)
概要 前面,我们已经学习了ArrayList.接下来,我们以ArrayList为例,对Iterator的fail-fast机制进行了解.内容包括::1 fail-fast简介2 fail-fast示例 ...
- Android项目实战_手机安全卫士手机防盗界面
#安全卫士手机防盗# ###1.Activity的任务栈 1.类似一个木桶,每层只能放一个木块,我们放入木块和取出木块的时候只能从最上面开始操作 ###2.Android中的坐标系![](http:/ ...
- 用最简单的脚本完成supertab的基本功能并实现一个更加合理的功能
supertab是vim的一个出名的插件, 相信会vim的人没几个不知道的, 我在之前的<<vim之补全1>>中首先说明的也是它, supertab实现的功能简单的说就是用ta ...
- Ubuntu用户自定义脚本开机启动
如果想让自己写的脚本随开机自动执行,可以这样做: 编辑文件/etc/init.d/rc.local,在最后添加用户自定义脚本的完整路径即可. 很简单有木有!!