Submission #1357897
Source Code Expand
#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 Info
Submission Time | |
---|---|
Task | D - Half Reflector |
User | alex99 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1261 Byte |
Status | RE |
Exec Time | 104 ms |
Memory | 640 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 900 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt |
All | 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | AC | 1 ms | 256 KB |
in10.txt | RE | 101 ms | 640 KB |
in11.txt | RE | 101 ms | 640 KB |
in12.txt | RE | 103 ms | 640 KB |
in13.txt | RE | 101 ms | 640 KB |
in14.txt | RE | 104 ms | 640 KB |
in15.txt | RE | 101 ms | 640 KB |
in16.txt | RE | 103 ms | 640 KB |
in17.txt | RE | 102 ms | 640 KB |
in18.txt | RE | 101 ms | 640 KB |
in19.txt | RE | 101 ms | 640 KB |
in2.txt | AC | 7 ms | 640 KB |
in20.txt | RE | 101 ms | 640 KB |
in21.txt | RE | 101 ms | 640 KB |
in22.txt | RE | 102 ms | 640 KB |
in23.txt | RE | 101 ms | 640 KB |
in24.txt | RE | 101 ms | 640 KB |
in25.txt | RE | 101 ms | 640 KB |
in26.txt | RE | 102 ms | 640 KB |
in27.txt | RE | 102 ms | 640 KB |
in28.txt | RE | 101 ms | 640 KB |
in29.txt | RE | 102 ms | 640 KB |
in3.txt | RE | 102 ms | 640 KB |
in30.txt | RE | 101 ms | 640 KB |
in31.txt | RE | 101 ms | 640 KB |
in32.txt | RE | 101 ms | 640 KB |
in33.txt | RE | 102 ms | 640 KB |
in34.txt | RE | 101 ms | 640 KB |
in35.txt | RE | 104 ms | 640 KB |
in36.txt | RE | 103 ms | 640 KB |
in37.txt | RE | 101 ms | 640 KB |
in38.txt | RE | 101 ms | 640 KB |
in39.txt | RE | 102 ms | 640 KB |
in4.txt | RE | 101 ms | 640 KB |
in40.txt | RE | 101 ms | 640 KB |
in41.txt | RE | 103 ms | 640 KB |
in42.txt | RE | 101 ms | 640 KB |
in5.txt | RE | 104 ms | 640 KB |
in543.txt | RE | 101 ms | 640 KB |
in557.txt | RE | 101 ms | 640 KB |
in6.txt | AC | 1 ms | 256 KB |
in7.txt | RE | 101 ms | 640 KB |
in8.txt | RE | 102 ms | 640 KB |
in9.txt | RE | 101 ms | 640 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | AC | 1 ms | 256 KB |