-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1907_B_YetnotherrokenKeoard.cpp
44 lines (41 loc) · 1 KB
/
1907_B_YetnotherrokenKeoard.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
43
44
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
string str;
cin >> str;
map<int, int> mp;
stack<int> st1;
stack<int> st2;
for(int i=0; i<str.size(); i++){
if(str[i] == 'b'){
if(!st1.empty()){
mp[st1.top()]++;
st1.pop();
}
}
else if(str[i] == 'B'){
if(!st2.empty()){
mp[st2.top()]++;
st2.pop();
}
}
else if(str[i] >= 'a' && str[i] <= 'z'){
st1.push(i);
}
else if(str[i] >= 'A' && str[i] <= 'Z'){
st2.push(i);
}
}
string res = "";
for(int i=0; i<str.size(); i++){
if(mp[i] < 1 && str[i] != 'b' && str[i] != 'B'){
res += str[i];
}
}
cout << res << endl;
}
return 0;
}