AtCoder Grand Contest 011

Submission #1357896

Source codeソースコード

#include <iostream>
using namespace std;
int N, K;
char Str[400005];
void Read()
{
    cin >> N >> K;
    cin.get();
    cin.getline(Str + 1, 200005);
    for(int i = N + 1; i <= 3 * N; i++)
        Str[i] = 'A';
}
inline char Code(char ch, int rev)
{
    if(rev == 0)
        return ch;
    if(ch == 'A')
        return 'B';
    return 'A';
}
void Solve()
{
    int start = 1, times = 0, rev = 0;
    while(start <= N * 2 && times < K)
    {
        if(Code(Str[start], rev) == 'A')
            Str[start] = Code('B', rev), times++;
        else
        {
            ++start;
            rev = 1 - rev;
            if(rev == 1)
                Str[start + N - 1] = 'B';
            times++;
        }
    }
    if(times == K)
    {
        for(int i = start; i <= start + N - 1; i++)
            cout << Code(Str[i], rev);
        cout << "\n";
        return;
    }
    times = K - times;
    if(N % 2 == 1)
    {
        for(int i = 1; i <= N / 2; i++)
            cout << "AB";
        cout << "A";
        cout << "\n";
    }
    else
    {
        for(int i = 1; i <= N / 2; i++)
            cout << "BA";
        cout << "\n";
    }
}
int main()
{
    Read();
    Solve();
    return 0;
}

Submission

Task問題 D - Half Reflector
User nameユーザ名 alex99
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 RE
Score得点 0
Source lengthソースコード長 1261 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample1.txt,sample2.txt,sample3.txt
All 0 / 900 sample1.txt,sample2.txt,sample3.txt,in1.txt,in10.txt,in11.txt,in12.txt,in13.txt,in14.txt,in15.txt,in16.txt,in17.txt,in18.txt,in19.txt,in2.txt,in20.txt,in21.txt,in22.txt,in23.txt,in24.txt,in25.txt,in26.txt,in27.txt,in28.txt,in29.txt,in3.txt,in30.txt,in31.txt,in32.txt,in33.txt,in34.txt,in35.txt,in36.txt,in37.txt,in38.txt,in39.txt,in4.txt,in40.txt,in41.txt,in42.txt,in5.txt,in543.txt,in557.txt,in6.txt,in7.txt,in8.txt,in9.txt,sample1.txt,sample2.txt,sample3.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
in1.txt AC 1 ms 256 KB
in10.txt RE
in11.txt RE
in12.txt RE
in13.txt RE
in14.txt RE
in15.txt RE
in16.txt RE
in17.txt RE
in18.txt RE
in19.txt RE
in2.txt AC 8 ms 640 KB
in20.txt RE
in21.txt RE
in22.txt RE
in23.txt RE
in24.txt RE
in25.txt RE
in26.txt RE
in27.txt RE
in28.txt RE
in29.txt RE
in3.txt RE
in30.txt RE
in31.txt RE
in32.txt RE
in33.txt RE
in34.txt RE
in35.txt RE
in36.txt RE
in37.txt RE
in38.txt RE
in39.txt RE
in4.txt RE
in40.txt RE
in41.txt RE
in42.txt RE
in5.txt RE
in543.txt RE
in557.txt RE
in6.txt AC 1 ms 256 KB
in7.txt RE
in8.txt RE
in9.txt RE
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB