You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R', 'G' and 'B' — colors of lamps in the garland).

You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the obtained garland is diverse.

A garland is called diverse if any two adjacent (consecutive) lamps (i. e. such lamps that the distance between their positions is 11) have distinct colors.

In other words, if the obtained garland is tt then for each ii from 11 to n−1n−1 the condition ti≠ti+1ti≠ti+1 should be satisfied.

Among all ways to recolor the initial garland to make it diverse you have to choose one with the minimum number of recolored lamps. If there are multiple optimal solutions, print any of them.

Input

The first line of the input contains one integer nn (1≤n≤2⋅1051≤n≤2⋅105) — the number of lamps.

The second line of the input contains the string ss consisting of nn characters 'R', 'G' and 'B' — colors of lamps in the garland.

Output

In the first line of the output print one integer rr — the minimum number of recolors needed to obtain a diverse garland from the given one.

In the second line of the output print one string tt of length nn — a diverse garland obtained from the initial one with minimum number of recolors. If there are multiple optimal solutions, print any of them.

Examples

input

Copy

9
RBGRRBRGG

output

Copy

2
RBGRGBRGR

input

Copy

8
BBBGBRRR

output

Copy

2
BRBGBRGR

input

Copy

13
BBRRRRGGGGGRR

output

Copy

6
BGRBRBGBGBGRG

思路:根据中间的改

代码;

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream> using namespace std; char a[200005];
int main()
{
int n;
cin>>n;
scanf("%s",a);
int s=0;
for(int t=0;t<n-1;t++)
{
if(a[t]==a[t+1])
{
s++;
if(a[t]!='R'&&a[t+2]!='R')
{
a[t+1]='R';
}
if(a[t]!='G'&&a[t+2]!='G')
{
a[t+1]='G';
}
if(a[t]!='B'&&a[t+2]!='B')
{
a[t+1]='B';
}
} } cout<<s<<endl;
puts(a); return 0;
}

Codeforces-D-Diverse Garland(思维)的更多相关文章

  1. Codeforces 1108D - Diverse Garland - [简单DP]

    题目链接:http://codeforces.com/problemset/problem/1108/D time limit per test 1 secondmemory limit per te ...

  2. D. Diverse Garland Codeforces Round #535 (Div. 3) 暴力枚举+贪心

    D. Diverse Garland time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  3. Diverse Garland CodeForces - 1108D (贪心+暴力枚举)

    You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ...

  4. CodeForces 483C Diverse Permutation

    Diverse Permutation Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64 ...

  5. Educational Codeforces Round 60 C 思维 + 二分

    https://codeforces.com/contest/1117/problem/C 题意 在一个二维坐标轴上给你一个起点一个终点(x,y<=1e9),然后给你一串字符串代表每一秒的风向, ...

  6. Educational Codeforces Round 61 F 思维 + 区间dp

    https://codeforces.com/contest/1132/problem/F 思维 + 区间dp 题意 给一个长度为n的字符串(<=500),每次选择消去字符,连续相同的字符可以同 ...

  7. [Codeforces 1178D]Prime Graph (思维+数学)

    Codeforces 1178D (思维+数学) 题面 给出正整数n(不一定是质数),构造一个边数为质数的无向连通图(无自环重边),且图的每个节点的度数为质数 分析 我们先构造一个环,每个点的度数都是 ...

  8. Sorted Adjacent Differences(CodeForces - 1339B)【思维+贪心】

    B - Sorted Adjacent Differences(CodeForces - 1339B) 题目链接 算法 思维+贪心 时间复杂度O(nlogn) 1.这道题的题意主要就是让你对一个数组进 ...

  9. Codeforces 675C Money Transfers 思维题

    原题:http://codeforces.com/contest/675/problem/C 让我们用数组a保存每个银行的余额,因为所有余额的和加起来一定为0,所以我们能把整个数组a划分为几个区间,每 ...

  10. codeforces 483C.Diverse Permutation 解题报告

    题目链接:http://codeforces.com/problemset/problem/483/C 题目意思:给出 n 和 k,要求输出一个含有 n 个数的排列 p1, p2, ...,pn,使得 ...

随机推荐

  1. Error: Cannot run program "/home/xxx/android_developer_tools/android-ndk-r8/ndk-build.cmd": Unknown reason

    运行OpenCV官方例子  tutorial-2-mixedprocessing 总提示  /home/xxx/android_developer_tools/ 明明在PATH中采用好几种方法都加入了 ...

  2. 激活 jave platform se

    1.有的网页上面会显示这个,但是点击后没反应 解决方案: firefox- >工具-附加组件管理器-“插件” 找到“Java(TM) Platform SE 7”,把“询问是否激活”改为“总是激 ...

  3. 第一天:tomcat相关知识和浏览器的访问机制

    1.tomcat的目录结构 1)bin目录:启动和关闭tomcat以及其他的脚本命令  2)conf目录:存放各种配置文件 a.server.xml配置文件的配置: *<host/>标签: ...

  4. 使用绘图API自定义组件

    -----------------siwuxie095                                 工程名:CustomizeSwing 包名:com.siwuxie095.swi ...

  5. 使用RSS提升DPDK应用的性能(转)

    本文描述了RSS以及在DPDK中如何配置RSS达到性能提升和统一分发. 什么是RSS RSS(Receive Side Scaling)是一种能够在多处理器系统下使接收报文在多个CPU之间高效分发的网 ...

  6. HDOJ 1164 Eddy's research

    上一篇已经讲了,但是转载别人的很乱,这里自己根据blog里面写的思路,重新写过了一个程序 #include <iostream> #include <malloc.h> #in ...

  7. Qt中显示图像的两种方法

    博客转载自:https://blog.csdn.net/lg1259156776/article/details/52325361 在Qt中处理图片一般都要用到QImage类,但是QImage的对象不 ...

  8. GCC 版本与C11标准

    1. GCC版本是否支持C11 C89=C90:gcc选项是:-ansi, -std=c90 or -std=iso9899:; 带了GNU扩展的:-std=gnu90 C94=C95:gcc选项:- ...

  9. Flash of Unstyled Content (FOUC)

    在这次的产品发布中,客户发现了一个问题,就是在Firefox浏览器中,页面在加载的时候,出现没有样式的内容一闪而过的现象.其实,在测试过程中,我们也看到了类似的问题,但是并没有意识到这是一个问题,以为 ...

  10. Java-数据结构与算法-选择排序与冒泡排序

    Java 选择排序与冒泡排序 1.DataSorter.java public class DataSorter { //冒泡排序法 //主要思路:按升序排序,数组元素两两比较,大的立即排后面 pub ...