-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5397.cpp
41 lines (36 loc) · 840 Bytes
/
5397.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
#include <bits/stdc++.h>
using namespace std;
int main(void){
ios::sync_with_stdio(0);
cin.tie(0);
int N=0;
cin>>N;
while(N--){
list<char> L;
list<char>::iterator iter=L.begin();
string s;
cin>>s;
for(auto c:s){
switch(c){
case '<':
if(iter!=L.begin()) iter--;
break;
case '>':
if(iter!=L.end()) iter++;
break;
case '-':
if(iter!=L.begin()){
iter--;
iter=L.erase(iter);
}
break;
default:
L.insert(iter,c);
}
}
for(auto c:L){
cout<<c;
}
cout<<endl;
}
}