CF Vicious Keyboard 构造水题
来源:互联网 发布:太阳黑子与气候数据 编辑:程序博客网 时间:2024/06/05 16:18
题目说 在给定字符串中 只能改变一个字符的情况下 求最大的VK字符的数量
分析
为了防止出错 这里要注意 为了防止VK判断的时候
不影响其他的判断 对于一个VK 我们最好不要把他删掉删掉后有可能会增加新的VK
就直接用特定值把原来的VK覆盖掉
然后对于剩下的可能 最多只能增加一个VK
就是通过 目标条件判断 计数就可以
#include<bits/stdc++.h>using namespace std;int main(){ string l; getline(cin,l); int pos=0,c=0; while(l.find("VK",0)!=string::npos){ pos = l.find("VK",pos); l[pos]=32,l[pos+1]=32; c++; } int v=0,k=0; for(int i=0;i<l.length();i++){ if(l[i]=='V'&&(i+1)<l.length()&&l[i+1]!=32)v++; else if(l[i]!=32&&(i+1)<l.length()&&l[i+1]=='K')k++;//下标操作 注意判断边界条件 } if(v||k)c++; cout<<c<<endl; return 0;}
阅读全文
0 0
- CF Vicious Keyboard 构造水题
- CF#801 A. Vicious Keyboard(字符串,水题)
- A. Vicious Keyboard
- Codeforces801A Vicious Keyboard
- A. Vicious Keyboard codeforce
- Codeforces801A Vicious Keyboard
- A. Vicious Keyboard
- A. Vicious Keyboard
- A. Vicious Keyboard Codeforce
- Codeforces 801A Vicious Keyboard
- CodeForces 801A Vicious Keyboard
- codeforces 801A Vicious Keyboard
- CF-Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)-A-Vicious Keyboard
- CodeForces 801A Vicious Keyboard 模拟
- 0519 G2n#W2B-B Vicious Keyboard
- Codeforces Round #409 (Div. 2) A. Vicious Keyboard
- cf 88b Keyboard
- CodeFroces 831B. Keyboard Layouts(构造题)
- 回溯法练习笔记(二)
- 11月23日笔记
- JavaScript进阶(对象、BOM、DOM、事件)
- CMMI受管理级过程方面
- 场景解析--Pyramid Scene Parsing Network
- CF Vicious Keyboard 构造水题
- 动态规划
- java面试必须get的技能
- Netty源码分析之二【贯穿Netty的大动脉──ChannelPipeline】
- python 可视化
- 蓝桥杯 基础训练 芯片测试
- 平衡二叉树
- 九九乘法表
- Keras