AtCoder Grand Contest 011

Submission #1357902

Source codeソースコード

#include <iostream>
using namespace std;
int N, K;
char Str[700005];
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();
    if(N == 1)
    {
        if(K % 2 == 1)
        cout << "B\n";
        else
            cout << "A\n";
        return 0;
    }
    Solve();
    return 0;
}

Submission

Task問題 D - Half Reflector
User nameユーザ名 alex99
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1402 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 AC 14 ms 1024 KB
in11.txt AC 14 ms 1024 KB
in12.txt AC 14 ms 1024 KB
in13.txt AC 14 ms 1024 KB
in14.txt AC 14 ms 1024 KB
in15.txt AC 14 ms 1024 KB
in16.txt AC 14 ms 1024 KB
in17.txt AC 14 ms 1024 KB
in18.txt AC 14 ms 1024 KB
in19.txt AC 14 ms 1024 KB
in2.txt AC 7 ms 640 KB
in20.txt AC 14 ms 1024 KB
in21.txt AC 14 ms 1024 KB
in22.txt AC 12 ms 1024 KB
in23.txt AC 12 ms 1024 KB
in24.txt AC 12 ms 1024 KB
in25.txt AC 12 ms 1024 KB
in26.txt WA
in27.txt AC 12 ms 1024 KB
in28.txt AC 14 ms 1024 KB
in29.txt AC 14 ms 1024 KB
in3.txt AC 14 ms 1024 KB
in30.txt AC 14 ms 1024 KB
in31.txt AC 14 ms 1024 KB
in32.txt AC 14 ms 1024 KB
in33.txt AC 14 ms 1024 KB
in34.txt AC 14 ms 1024 KB
in35.txt AC 14 ms 1024 KB
in36.txt AC 14 ms 1024 KB
in37.txt AC 15 ms 1024 KB
in38.txt AC 15 ms 1024 KB
in39.txt AC 14 ms 1024 KB
in4.txt AC 12 ms 1024 KB
in40.txt AC 14 ms 1024 KB
in41.txt AC 14 ms 1024 KB
in42.txt AC 14 ms 1024 KB
in5.txt AC 12 ms 1024 KB
in543.txt AC 13 ms 1024 KB
in557.txt AC 13 ms 1024 KB
in6.txt AC 1 ms 256 KB
in7.txt AC 14 ms 1024 KB
in8.txt AC 12 ms 1024 KB
in9.txt AC 14 ms 1024 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB