Untitled
unknown
plain_text
a year ago
762 B
10
Indexable
#include <bits/stdc++.h>
using namespace std ;
#include <algorithm>
#define int long long
#define For(n) for(int i = 0; i < n; i++)
void solve ()
{
string s;
while(cin>>s)
{
deque<string>str;
string temp ="";bool b = true;
For(s.length()){
if(s[i] == '['){
b = false;
i++;
}
if(s[i] ==']'){
b = true;
i++;
}
while (s[i] != '['&&s[i]!=']'&&i < s.length()){
temp+= s[i++];
}i--;
if(b) str.push_back(temp);
else str.push_front(temp);
temp="";
}
for(auto it :str) cout << it ;cout << endl;
}
}
signed main ()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t;cin>>t;
while(t--)
{
solve();
}
return 0;
}
Editor is loading...
Leave a Comment