#include<bits/stdc++.h>
using namespace std;
char s[200007];
int ans[200007];
int main(){
    int n,k;
    int i=0,j=0,l=0;
    scanf("%d%d",&n,&k);
    scanf("%s",s+1);
    for(i=1;i<=n;i++)
        if(s[i]=='A')
            ans[i]=1;
    int tmp=0;
    for(i=1,j=1;i<=k&&j<=n;i++){
        if(ans[j]^tmp){//如果这一位经历异或之后变为了1需要再变一次把它变成0,因为这一位终将变成相当于这一步的开头第一位
            ans[j]^=1;//将它变成0
            continue;
        }
        tmp^=1;//变化异或标记
        j++;//进入下一位
    }
    if(i>=k+1){//k太小以至于前面还有剩余没有变为最终形态
        for(l=j;l<=n;l++)
            if(ans[l]^tmp)//后面的位数根据奇偶性进行变化
                printf("A");
            else
                printf("B");
        for(l=n+1;l<=n+j-1;l++)//最后面是找出的规律
            if((n+j-l)&1)
                printf("A");
            else
                printf("B");
    }
    else{
        if(n&1){//奇数则判断开头剩余是规律
            if((k-i+2)&1)
                printf("A");
            else
                printf("B");
            for(l=2;l<=n;l++)
                if(l&1)
                    printf("A");
                else
                    printf("B");
        }
        else
            for(l=1;l<=n;l++)
                if((l+1)&1)
                    printf("A");
                else
                    printf("B");
    }
    return 0;
}

AtCoder Grand Contest 011D(思维,规律,异或)的更多相关文章

  1. Atcoder Grand Contest 039B(思维,BFS)

    #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;int col[207],s[207],n;c ...

  2. AtCoder Grand Contest 019 B - Reverse and Compare【思维】

    AtCoder Grand Contest 019 B - Reverse and Compare 题意:给定字符串,可以选定任意i.j且i<=j(当然i==j时没啥卵用),然后翻转i到j的字符 ...

  3. Atcoder Grand Contest 024 E - Sequence Growing Hard(dp+思维)

    题目传送门 典型的 Atcoder 风格的计数 dp. 题目可以转化为每次在序列中插入一个 \([1,k]\) 的数,共操作 \(n\) 次,满足后一个序列的字典序严格大于前一个序列,问有多少种操作序 ...

  4. AtCoder Grand Contest 012

    AtCoder Grand Contest 012 A - AtCoder Group Contest 翻译 有\(3n\)个人,每一个人有一个强大值(看我的假翻译),每三个人可以分成一组,一组的强大 ...

  5. AtCoder Grand Contest 031 简要题解

    AtCoder Grand Contest 031 Atcoder A - Colorful Subsequence description 求\(s\)中本质不同子序列的个数模\(10^9+7\). ...

  6. AtCoder Grand Contest 004

    AtCoder Grand Contest 004 A - Divide a Cuboid 翻译 给定一个\(A*B*C\)的立方体,现在要把它分成两个立方体,求出他们的最小体积差. 题解 如果有一条 ...

  7. AtCoder Grand Contest 011

    AtCoder Grand Contest 011 upd:这篇咕了好久,前面几题是三周以前写的... AtCoder Grand Contest 011 A - Airport Bus 翻译 有\( ...

  8. AtCoder Grand Contest 010

    AtCoder Grand Contest 010 A - Addition 翻译 黑板上写了\(n\)个正整数,每次会擦去两个奇偶性相同的数,然后把他们的和写会到黑板上,问最终能否只剩下一个数. 题 ...

  9. AtCoder Grand Contest 009

    AtCoder Grand Contest 009 A - Multiple Array 翻译 见洛谷 题解 从后往前考虑. #include<iostream> #include< ...

随机推荐

  1. CentOS6.5下安装mongodb

    MongoDB是目前最常用的NoSQL-非关系型数据库. 本文将介绍在CentOS下如何通过yum安装MongoDB. 1.首先在CentOS6.5下,编辑Mongo的yum源: 在/etc/yum. ...

  2. java代码。从键盘输入次数。可控制的

    总结:把一碗水端平,本来水就不多. package com.b; import java.util.Scanner; //想办法用数组.一次性,多个的输出分解质因数 public class fa4 ...

  3. Spring之3:BeanFactory、ApplicationContext、ApplicationContextAware区别

    在Spring中系统已经为用户提供了许多已经定义好的容器实现,而不需要开发人员事必躬亲.相比那些简单拓展BeanFactory的基本IoC容器,开发人员常用的ApplicationContext除了能 ...

  4. Oracle logminer 分析redo log(TOAD与PLSQL)

    Oracle logminer 分析redo log Oracle 11g r2 RAC centos 6.5 设置时间格式 select to_char(sysdate,'yyyy-mm-dd hh ...

  5. git学习4 常用命令

    1:更新: 更新后,更新只在Workspace中,没有到暂存区.git status可以查看当前状态. git add <file>  可以放到待提交区.      git  checko ...

  6. python的程序书写以及保存

    在前面的微博里已经叙述Python的安装以及路径的设置. 在我们的windows的电脑上面我们已经安装完了python以及设置了它的路径,所以我们可以再cmd里面进行Python的编写(cmd的快速打 ...

  7. Android指针管理:RefBase,SP,WP (二)

    (1)在Android中,RefBase结合了sp和wp,实现了一套通过引用计数的方法来控制对象声明周期的方法. RefBase的定义在/frameworks/base/include/utils/R ...

  8. 一堵墙IFC数据-wall.ifc

    这是一面墙的IFC数据内容 =====================================文档内容======================================= ISO-1 ...

  9. 36-图像有用区(dfs, bfs)

    http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=92 图像有用区域 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   ...

  10. android sdk更新源

    什么是Android SDK: SDK:(software development kit)软件开发工具包.被软件开发工程师用于为特定的软件包.软件框架.硬件平台.操作系统等建立应用软件的开发工具的集 ...