-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstpcF.cpp
42 lines (40 loc) · 812 Bytes
/
stpcF.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <bits/stdc++.h>
using namespace std;
vector<char> S;
void push_B(){
if(!S.empty()){
if(S.back()=='C'){
S.pop_back();
push_B();
S.push_back('A');
}else if(S.back()=='A'){
S.pop_back();
S.push_back('C');
}else{
S.push_back('B');
}
}else{
S.push_back('B');
}
}
int main(void){
ios::sync_with_stdio(0);
cin.tie(0);
int N;
cin>>N;
while(N--){
int k;
cin>>k;
while(k--){
char input;
cin>>input;
if(input=='B') push_B();
else S.push_back('A');
}
for(auto c:S) {
if(c=='C')
cout<<"BA";
else cout<<c;
}cout<<'\n';
}
}