Codeforces Round #409 (Div. 2) A. Vicious Keyboard
来源:互联网 发布:淘宝店铺策划书童装 编辑:程序博客网 时间:2024/05/04 05:32
题目链接:Vicious Keyboard
题目大意:给一串只包含V和K的字符,最多替换一次V为K或者K为V,问字符串中最多能出现多少次VK
题目思路:这题都没能一次AC啊,真菜,直接算出来最开始有多少个V看,然后遍历整个字符串,把V替换成K,K替换成V再算,每次求最大值就可以了
#include <bits/stdc++.h>using namespace std;typedef long long ll;int solve(string s){ int res = 0; for(int i = 1;i <= s.size();i++){ if(s[i-1] == 'V'&&s[i] == 'K') res++; } return res;}int main(){ ios::sync_with_stdio(false); string s; cin>>s; int ans = solve(s); for(int i = 0;i < s.size();i++){ string cur = s; if(cur[i] == 'V') cur[i] = 'K'; else cur[i] = 'V'; ans = max(ans,solve(cur)); } cout<<ans<<endl; return 0;}
0 0
- Codeforces Round #409 (Div. 2) A. Vicious Keyboard
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) A. Vicious Keyboard
- CF-Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)-A-Vicious Keyboard
- Codeforces 801A Vicious Keyboard
- CodeForces 801A Vicious Keyboard
- codeforces 801A Vicious Keyboard
- Codeforces Round #271 (Div. 2) A. Keyboard
- CodeForces 801A Vicious Keyboard 模拟
- Codeforces Round #271 (Div. 2) --A Keyboard (暴力)
- A. Vicious Keyboard
- A. Vicious Keyboard codeforce
- A. Vicious Keyboard
- A. Vicious Keyboard
- A. Vicious Keyboard Codeforce
- 【Codeforces Round 271 (Div 2)A】【水题】Keyboard 打字列偏移还原原始串
- Codeforces Round #409 Div. 2(A+B)
- codeforces Round #474--A.Keyboard
- Codeforces Round #424 (Div. 2) B. Keyboard Layouts(字符串)
- BZOJ 1251: 序列终结者
- ASP+AJAX做类似google的搜索提示
- 题目1074:对称平方数
- HotApp小程序统计开发总结之设置了navigationBarBackgroundColor颜色,android 可以显示,ios不能显示
- 在Windows下搭建YOLO v2开发环境
- Codeforces Round #409 (Div. 2) A. Vicious Keyboard
- 如何保持Oracle数据库SQL性能的稳定性
- SQL Server中开发常用的数据类型
- 每日一句:Move On
- 情愫有感
- JAVA_IO_文件读取_细节
- 配置redis外网可访问,并只允许指定的ip可访问redis
- lintcode(42)最大子数组 II
- 一个单表查询的示例