Codeforces 665C Simple Strings【暴力,贪心】
来源:互联网 发布:北京哪里有mac专柜 编辑:程序博客网 时间:2024/05/01 17:30
题目链接:
http://codeforces.com/contest/665/problem/C
题意:
改变最少的字符,使得最终序列无相同的连续的字符。
分析:
对每一个与前一个字符相同的字符,枚举满足条件的字符进行替换。
代码:
#include<iostream>using namespace std;int main (void){ string s;cin>>s; int n = s.length(); for(int i = 1; i < n; i++){ if( s[i] == s[i - 1]){ for(int j = 0; j < 26; j++){ char t = j + 'a'; if(t != s[i - 1] && t != s[i + 1]){ s[i] = t; break; } } } } cout<<s<<endl; return 0;}
0 0
- Codeforces 665C Simple Strings【暴力,贪心】
- CodeForces 665C Simple Strings
- Codeforces 665C - Simple Strings
- CodeForces 665C Simple Strings
- codeforces C. Simple Strings
- CodeForces 665C C - Simple Strings
- Educational Codeforces Round 12 C. Simple Strings 贪心
- Educational Codeforces Round 12 C.Simple Strings
- CodeForeces 665C Simple Strings
- Simple Strings CodeForces
- Codeforces 401C Team(贪心+暴力)
- Codeforces 665C Smple Strings
- Codeforces 526C - Om Nom and Candies(贪心,暴力)
- !codeforces 399C Cards-数论&贪心-(暴力枚举)
- 暴力 + 贪心 --- Codeforces 558C : Amr and Chemistry
- CodeForces 723C Polycarp at the Radio (贪心+暴力)
- codeforces 762C Strings
- codeforces B. Mike and strings 暴力+字符串
- Web前端性能优化(九)图像和Cookie优化
- 最短编辑距离
- 用到MNIST数据集的实验(总结中……)
- 【LeetCode】 17. Letter Combinations of a Phone Number
- 学生信息系统之优化(一)之ascii码
- Codeforces 665C Simple Strings【暴力,贪心】
- linux命令
- 处理TAP国际漫游话单的几种类库使用方法
- 关于conversation generation的论文笔记
- 1.认识Makefile文件
- 2015年终总结
- python实现简单爬虫功能
- 2.变量
- STM32_DAC输出电压