Codeforces 665C Simple Strings【暴力,贪心】
题目链接:
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;
}
Codeforces 665C Simple Strings【暴力,贪心】的更多相关文章
- codeforces 665C Simple Strings
相同的一段字母变一下就可以. #include<cstdio> #include<cstring> #include<cmath> #include<vect ...
- CodeForeces 665C Simple Strings
C. Simple Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- Codeforce-Ozon Tech Challenge 2020-B. Kuroni and Simple Strings(贪心)
B. Kuroni and Simple Strings time limit per test1 second memory limit per test256 megabytes inputsta ...
- Codeforces 626E Simple Skewness(暴力枚举+二分)
E. Simple Skewness time limit per test:3 seconds memory limit per test:256 megabytes input:standard ...
- Educational Codeforces Round 12 C. Simple Strings 贪心
C. Simple Strings 题目连接: http://www.codeforces.com/contest/665/problem/C Description zscoder loves si ...
- codeforces 665C C. Simple Strings(乱搞)
题目链接: C. Simple Strings time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces Round #503 (by SIS, Div. 2) C. Elections (暴力+贪心)
[题目描述] Elections are coming. You know the number of voters and the number of parties — n and m respe ...
- codeforces Gym 100338E Numbers (贪心,实现)
题目:http://codeforces.com/gym/100338/attachments 贪心,每次枚举10的i次幂,除k后取余数r在用k-r补在10的幂上作为候选答案. #include< ...
- [Codeforces 1214A]Optimal Currency Exchange(贪心)
[Codeforces 1214A]Optimal Currency Exchange(贪心) 题面 题面较长,略 分析 这个A题稍微有点思维难度,比赛的时候被孙了一下 贪心的思路是,我们换面值越小的 ...
随机推荐
- Java简答题附答案
1. Java有没有goto? 有, Goto语句在java中作为保留字, 并没有实现它. 带标号的break, continue局限于循环体中跳转 带标号的goto可以在一个函数(c语言)中任意跳转 ...
- 【图论】hdu6370Werewolf
有理有据的结论题 Problem Description "The Werewolves" is a popular card game among young people.In ...
- 安装mongodb卡顿
"3.6下载安装会卡死."的原因在于,默认安装是包含mongodb compass,这个包的,这个包大约有180MB,下载很慢,导致所谓的的”卡死“. 如果你选用自定义安装的并且不 ...
- grunt与requirejs结合使用
// 多个js压缩成一个js // Project configuration. module.exports = function(grunt) { // 使用严格模式 'use strict'; ...
- 【18】什么是FOUC?如何避免
[18]什么是FOUC?如何避免 Flash Of Unstyled Content: 用户定义样式表加载之前浏览器使用默认样式显示文档,用户样式加载渲染之后再从新显示文档,造成页面闪烁. 解决方法: ...
- vmware安装CentOS " Intel VT-x 处于禁用状态"
我刚用虚拟机vmware 11安装CentOS 7 ,出现错误“此主机支持 Intel VT-x,但 Intel VT-x 处于禁用状态”的问题,如下图. Intel VT-x 即Virtualiza ...
- Leetcode 363.矩形区域不超过k的最大数值和
矩形区域不超过k的最大数值和 给定一个非空二维矩阵 matrix 和一个整数 k,找到这个矩阵内部不大于 k 的最大矩形和. 示例: 输入: matrix = [[1,0,1],[0,-2,3]], ...
- Palindromic Paths(DP)
描述 Given an N×N grid of fields (1≤N≤500), each labeled with a letter in the alphabet. For example: A ...
- 【JavaScript 11—应用总结】:下拉菜单
导读:在web页面的显示中,总是免不了下拉菜单的设置.怎样将菜单设置的更好玩一点呢?这次,就将实现一个下拉菜单的制作.当鼠标移入的时候,菜单显示,鼠标移走,菜单关闭. 一.实现分析 首先,制作一个下拉 ...
- WCF学习-协议绑定
文章:无废话WCF入门教程三[WCF的宿主] 讲了net.tcp协议的wcf绑定.